Gravity Forms WPMU DEV Membership plugin

Hey all,

I followed the directions here - https://premium.wpmudev.org/forums/topic/gravity-forms-and-membership-signup#post-232538

to attempt to utilize Gravity Forms and Membership plugin together. The flow is correct when logged in. For example - if I am logged in as a user, use Gforms to create a new user (with registration add-on), it does in fact create the user, and then...based on my package selection confirmation redirect, takes me to the correct link.

Trying it as a visitor to the site (not logged in) after adding the snippet mentioned in the previous thread, which auto login's the user, it instead sends me to the default registration page for membership plugin.

I am assuming the code snippet added to functions.php is off. Anyone else done this successfully? What is the code which should be added to functions.php? I have

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
) );
}

  • Alexander
    • DEV MAN’s Mascot

    @zerozendesign,

    When the user is redirected, can you confirm whether or not it actually logs them in automatically?

    The code looks correct, but it's possible that the action hook is no longer used, or needs to be implemented differently.

    Best regards,

  • Alexander
    • DEV MAN’s Mascot

    Hi @zerozendesign,

    I've looked into this a bit, and the code should work according to what I'm seeing in the gravity forms user registration code. That action is called right after the user gets created.

    It could be that because the account hasn't been activated, it's preventing the signup from happening. You could also try an alternative sign in code like this:

    $userbylogin = get_user_by( 'login', $user );
    		if(!empty($userbylogin)) {
    			@wp_set_auth_cookie($userbylogin->ID);
    			wp_set_current_user($userbylogin->ID);
    		}

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.