I would like to have a user automatically logged in after registering for a free trial. I current have the User Registration and Pay Pal Add-on's in place and properly configured. I added the following code to functions.php:
add_action( 'gform_user_registered', 'pi_gravity_registration_autologin', 10, 4 );
/**
* Auto login after registration.
*/
function pi_gravity_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
) );
}
When I submit a registration without the Pay Pal integrated it registers the user and auto logs them into the site just fine. It's when I have the Pay Pal add-on running where the user is redirected to Pay Pal and returns to the site. The problem is that it is not auto-logging them into the site after returning from Pay Pal. The user is registered and can log in. Also, the payment/trial information is processing just fine. It just seems to be the auto login part that is not working.
I'm almost certain it has something to do with the Pay Pal add-on, just not sure what. Please advise.
Thank you.