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 ] ) ){
		return esc_attr( $_REQUEST[ $key ] );
	}
    return "";
}

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
Leave a Response

Leave a Reply

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