Automatically Login after User Registration with Gravity Forms

The default behavior in wordpress after registration is to then require the user to login with the account information that they just created. Unless you are using an email confirmation step, this login requirement is an annoying extra step for the user and isn’t necessary. The ideal behavior is to automatically login to the system after registration is complete.

If you have a Gravity Forms developer license, then you get access to the advanced form add-ons including the “User Registration” add-on. Using the “User Registration” add-on we can make this automatic login happen very easily and that is what we are going to look at in this guide.

How to Automatically Login with Gravity Forms User Registration

All you need to do is add the following code snippet to your child theme’s functions.php file.

add_action( 'gform_user_registered', 'vc_gf_registration_autologin',  10, 4 );
function vc_gf_registration_autologin( $user_id, $user_config, $entry, $password ) {
	$user = get_userdata( $user_id );
	$user_login = $user->user_login;
	$user_password = $password;

    wp_signon( array(
		'user_login' => $user_login,
		'user_password' =>  $user_password,
		'remember' => false

    ) );
}

That’s all there is to it. Making it automatically login the user is just one tweak that you can do to your user registration form in gravity forms among many others. You’ll get many more options with the gravity forms user registration than you would with the traditional wordpress registration form.

You must have a developer’s license to get access to the “User Registration” add-on and that comes with a hefty price tag. Renewing the annual license is half-price, so once you get it I recommend keeping it. Unfortunately, they don’t sell the add-on’s individually. As long as you have enough work, the developer license with unlimited use makes it totally worthwhile. For any developer churning out many projects, it is definitely worth it in the long run as Gravity forms offers the most possibilities as far as WordPress form plugins go.

If you only need something more lightweight or free, then I would recommend trying out Contact Form 7, which I have also used frequently.

Speak Your Mind

*