Auto login after user registration not working [RESOLVED]

I bring this issue up here because I have needed this to work on two different sites in the last week and have been unable to get it to work. I am using the following code to log in a user after registration, but no matter how much tinkering I do, it just does not log the user in! Any ideas what I’m doing wrong here?

function jh_gravity_registration_autologin( $user_id, $feed, $entry, $password ) {
     if ( !is_user_logged_in() ) {
		$user = get_userdata( $user_id );
		wp_signon( array(
			'user_login' => $user->user_login,
			'user_password' => $password,
			'remember' => false
		) );
add_action( 'gform_user_registered', 'jh_gravity_registration_autologin', 10, 4 );

Any ideas would be greatly appreciated!

Hi Joe. Add-on feed processing has been moved to the background by default to improve form submission performance. This means the feeds are processed in a separate request where the user isn’t present.

Auto-login isn’t compatible with background feed processing because the current user object and auth cookie are set in the request where the user isn’t present.

You can use the following filter to disable background feed processing for the add-on so that the feed will be processed in the same request as the form submission:

Brilliant. That worked perfectly. Thank you!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.