I know that this question has already been answered, but for those who are looking for a solution that does not require a plugin, I decided to do the following.
First I created my form from the plugin through the Wordpress toolbar. I added a field in which I wanted to save the parameter from the URL, and assigned it an identifier.
[text page-name class:form-control id:source minlength:2 maxlength:80]
Next, I added a link that would pass such a parameter to the form
<a href='http://mycoolwebsite.com/contact?id=homepage'>Contact Us</a>
Then, using some Javascript and JQuery , I get the id parameter from the URL and set it as the value for my input on the form. (The getParameterByName(name,url) function was taken from this answer: How to get query string values ββin JavaScript? )
function getParameterByName(name, url) { if (!url) url = window.location.href; url = url.toLowerCase(); name = name.replace(/[\[\]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, " ")); } var param = getParameterByName('id'); jQuery('#source').hide(); jQuery('#source').prop('disabled', true); jQuery('#source').attr('value', param); jQuery('#source').val(param);
I also hide and disable the input field so that it is not visible and cannot be changed (easily). I also hide the input box using CSS
#source{visibility:hidden}
Thus, I can link to the form from anywhere on my site and add the source of where the person came from and put it in the received letter.
I do not see any problems with this method, and this eliminates the need to use a plugin. I am sure that this is not ideal to depend on Javascript, but equally it is not ideal for use with many plugins on your site, as they can quickly become outdated and can often cause conflicts among themselves.
Hope this helps anyone looking for an alternative. I would like to know the opinions of people along the way, as I am open to suggestions on how to improve it.