add_filter( 'gform_field_value_refurl', 'populate_referral_url'); function populate_referral_url( $form ){ // Grab URL from HTTP Server Var and put it into a variable $refurl = $_SERVER['HTTP_REFERER']; // Return that value to the form return esc_url_raw($refurl); }