Auto Login via Gravity Forms Problem

I am auto logging in new subscribers via gravity forms for a few reasons, which then on submit directs to the subscription packages.

Problem - If someone closes down the "choose a subscription page" at this point and because they are auto logged in it seems to put them at the lowest subscription paid level - which gives them some access that they shouldn't have.

I created a new subscription level, called "site visitor" which is private, and has a finite subscription of 1 day with no charge and no access to restricted content. However new users that do not choose a plan are still defaulting to the lowest membership package and accessing paid for content.

Can't seem to figure this out. Any clues?

Here's the auto login used

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
    ) );
}
  • Louise
    • Design Lord, Child of Thor

    Tried it with None or at the Free subscription level and it auto logs in and gives access

    Is there a way to set the auto log in as a "subscriber" role initially and then the membership plug in should upgrade on purchase?

  • Louise
    • Design Lord, Child of Thor

    Fixed this - adding an extra line to the auto sign in gives it the default role of subscriber which is then upgraded once a membership role is selected.

    Very nifty

    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;
           $user->set_role(get_option('default_role', 'subscriber'));
    
        wp_signon( array(
    		'user_login' => $user_login,
    		'user_password' =>  $user_password,
    		'remember' => false
    
        ) );
    }

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.