Getting the URL correctly

Remove the {embed_url} code,

  1. Create a hidden field on your form.
  2. Allow the field to be populated dynamically by accessing the advanced tab and enabling the checkbox.
  3. Give it a parameter name: refurl

Then add the following code at the bottom of your enabled theme’s functions.php file

add_filter( ‘gform_field_value_refurl’, ‘populate_referral_url’);
function populate_referral_url( $form ){
$refurl = $_SERVER[‘HTTP_REFERER’];
return esc_url_raw($refurl);

Then you will get the current url

Join the Conversation


Leave a comment

Your email address will not be published. Required fields are marked *