I'm a site administrator/content manager who wants to add functionality to a Drupal 8 site. I do NOT have a background in development (though I can make small modifications to code).
I am creating a product review site which reviews a certain kind of consumer product. The review form has a field for link to one particular ecommerce site. (not amazon.com, but like amazon).
This ecommerce site runs an affiliate marketing program which allows me to earn affiliate fees if my referral results in a sale.
I need all input of user URLs to append the code for my affiliate marketing account at the end of the URL ie. ,
One field in this review form will be othercommercesiteURL
When the user inputs http://www.othercommercesite.com/product3153.html
into the form, I want the data to be stored (and displayed) as http://www.othercommercesite.com/product3153.html?ref=myaffiliateaccount
.
Ideally, I'd need to check first if the user input URL doesn't already include the affiliate suffix, but I'd be happy with a way just to append this suffix. Because the URL will inputted in a form field labeled "Othercommercesite.com" I know the URL's are all going to go to this site.
How to accomplish this? Is there anything in Drupal 8 that already have this functionality (or something similar)?
hook_form_alter
. This related question might help: drupal.stackexchange.com/questions/23411/… Alternatively, you could probably get what you want using the module drupal.org/project/rewrite_field or a similar module - what you're looking to do in drupal-speak is alter the content of an entity field after input