Pass field value form 1 to html on form 2 [RESOLVED]

This may be pie in the sky.

But is it possible to pass a field value from one form to the other but inside an html field on the second form?

Whys you ask? What’s the use case?

I have a WhatsApp button on form 2 and it would be good to have the persons name on the WhatsApp click string.

Some guidance would be appreciated thanks.

Disclaimer I am not a PHP expert and this is typically outside of the questions I answer but I know the community is kind of offline on weekends. I put together something for you below. If none of this works you can always look into
Gravity Forms Populate Anything or also the URL params plugin

My solution (untested)
I’m assuming your first form is the one that gets the user’s name?

What you should do is set up a redirect confirmation on form1 to redirect to form2 and then in the ‘Pass Field Data via Query String’ field on form 1 enter name=and then select the merge tag from the merge tag dropdown which populates the name field.

Add this shortcode to your functions.php file.

add_shortcode('whatsapp_link', 'whatsapp_url_function'); 
function whatsapp_url_function( $atts ) { 
 extract( shortcode_atts( array(
 'whatsappurl' => '',
 ), $atts ) );
 // Get var from parameter in Gravity Forms confirmation page url
 $whatsapp_link_url = $_GET[$whatsappurl]; // this $whatsappurl word has to be the same as the word in the extract above (but without the $)
 // you can test with: return $_GET[$whatsappurl];

// Change the first part of the url to the whatsapp URL but leave the /$whatsapp_link_url variable
 if( $whatsapp_link_url != '' ) {
 return '$whatsapp_link_url'; 

Lastly, on form 2 in the HTML field add the shortcode [whatsapp_link whatsappurl=‘name’]

Shortcode snippet attribute
Sarah Moyer

Thanks Derek.

The field I wish to pass from form 1 is FirstName and append it to a url string on form2 html field.

I will have a play.

In short I cannot pass the variable to the html field. It doesn’t get passed.

Maybe one of the gravity team can shed light on it.

Thanks for the help Derek. Your time is appreciated.

Right I drilled down through Sarahs post. The solution was in a post on stack exchange. Now when I use the shortcode below it ouputs the first name in html field. Quite a game changer for me really as ads some great flexibility for personalisation of the form.

[URLParam param='NameFirst']

Per the OP’s answer within their question:

With your help and some Googling, I put together a shortcode that returns the value of any url parameter. Here it is:

function URLParam( $atts ) {  
    extract( shortcode_atts( array(
        'param' => 'param',
    ), $atts ) );
    return $_GET[$param];  
add_shortcode('URLParam', 'URLParam'); 

I use the shortcode like this to get the trip_type from my URL:

[URLParam param='NameFirst']
1 Like

Glad you got it to work.

1 Like