PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

{user:display_name} in HTML block?

  1. Hi - had a scour through forums but can't see solution for this.
    I have a multipage form.
    On page one it has 'Name' field.
    I would like the "Name' entered to appear in an html block on the final page.
    So that it reads " Thank-you for your form submission {user:display_name} "
    Possible?

    Posted 12 years ago on Wednesday March 7, 2012 | Permalink
  2. Hi, SlickSites,

    Yes, this is possible. You can display data from one page on another by using the "gform_pre_render" hook (http://www.gravityhelp.com/documentation/page/Gform_pre_render). Below is an example I provided to another user where they displayed the name on the second page of their multi-page form:

    add_filter("gform_pre_render", "populate_welcome");
    function populate_welcome($form)
    {
    	//only get data form form id 31 (or use gform_pre_render_31)
    	if ($form["id"] == 31)
    	{
    		//check what page you are on
    		$current_page = GFFormDisplay::get_current_page($form["id"]);
    		if ($current_page == 2)
    		{
    			//set the field on page 2 to the first/last name from page 1
    			//get the name
    			$first = rgpost("input_1_3"); //first name field when using the normal name format broken into two fields (was field 1 on this form)
    			$last = rgpost("input_1_6"); //last name field when using the normal name format broken into two fields (was field 1 on this form)
    			foreach($form["fields"] as &$field)
    			{
    				//html field (field id 3) on second page which will display name from first page
    				if ($field["id"] == 3)
    				{
    					$field["content"] = "Welcome, " . $first . " " . $last;
    				}
    			}
    		}
    	}
    	//return altered form so changes are displayed
    	return $form;
    }

    If you simply want to display this info in your confirmation text, in your Form Settings, you can use "Insert Merge Tag" and select your field. You can use HTML in there as well.

    Take a look and let me know if you have questions.

    Posted 12 years ago on Wednesday March 14, 2012 | Permalink

This topic has been resolved and has been closed to new replies.