Dynamically Populate Register form fields from URL parameters

-
Screen Shot 2020-05-14 at 1.02.51 AM

Gravity Form, Formidable form & Contact Form 7 – what do these advanced form builders have in common? They accept URL parameters to auto fill form fields!

In this tutorial, you will learn how to enable this feature in Ultimate Member 2.0+ with easy steps below.

  1. Add the following code snippet to your theme’s function.php file
add_filter("um_field_value","um_custom_register_clear_value",10 ,5 );
function um_custom_register_clear_value( $value, $default, $key, $type, $data  ){
    
	if( isset( $_REQUEST[ $key ] ) && function_exists("um_is_core_page") && um_is_core_page("register") ){
		return esc_attr( $_REQUEST[ $key ] );
	}
    return $value;
}

2. Check the field names that you want to get populated with URL parameter values.

Go to WP Admin > Ultimate Member > Forms > Edit a Register Form > Click on the “pen” icon to edit the field. Meta Key is the field name!

3. Go to the Register Page and add your URL parameters. Ensure that the parameter key matches your field name/meta key.

If you have the pre-defined fields such as Email Address, First Name and Last Name, your URL parameters would look something like this

/register/[email protected]&first_name=champ&last_name=camba

So that’s how you enable the dynamic auto fill feature in Ultimate Member. Let me know in the comment section if you have encountered any issues with this tutorial! Don’t forget to subscribe to my newsletter to get weekly Ultimate Member Development tips and tricks!

Subscribe to our newsletter!

Help me reach other people who need the help

4 Comments Dynamically Populate Register form fields from URL parameters

  1. Quite good feature 🙂

    It works fine. But I have a problem on my site 🙁

    With this code snippet enabled, the UM account page is blank. Or rather the fields. I cannot see the information: Id, first name, last name, email, …

    How to correct this and see the fields value on the account page? And still populate Register form fields from URL parameters 🙂

    Thanks 🙂

    1. Hi Greg!

      Thanks for letting me know. I’ve updated the code above. Let me know if you’re still encountering issues 🙂

      Regards,

  2. Hello Champ Camba, can you confirm if this is still working right now? or we need to refactor the code in someway i tried using it but i don’t seem to get it working i don’t know why

Leave a Reply

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