Skip Navigation

[Resolved] Auto Login stopped working

This support ticket is created 4 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by richardG-4 4 years ago.

Assisted by: Shane.

Author
Posts
#1595129

The auto login function the Toolset devs helped me make stopped working. It's a pretty simple form, I'm not sure where it could be failing. Maybe there was a WordPress or Toolset update that changed some of these functions?

This is how it work
1. Users create an account with a Toolset user form at hidden link
2. The form redirects to a content creation form, which requires users be logged in.
3. The function is supposed to log them in so they can fill out the form.

The form ID for the member-sign-in is 1187.

 
//////////
//Auto log-in new user
 
add_action( 'cred_save_data', 'tssupp_cred_autologin', 10, 2 );
function tssupp_cred_autologin( $post_id, $form_data ){
   
    if ( 1187 == $form_data['id'] ) {
   
        if ( !empty( $_POST['user_email'] ) && !empty( $_POST['user_pass'] ) ) {
   
            $user = get_user_by( "email", $_POST['user_email'] );
 
            $signon = array(
                'user_login'    => $user->user_login,
                'user_password' => $_POST['user_pass'],
                'remember'      => true
            );
 
            $login = wp_signon( $signon, false );
   
            if ( is_wp_error($login) ) {
                error_log( $login->get_error_message() );
            }
        }
    }
}

I have a temporary admin account ready if you need to poke around in there.

#1595971

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Richard,

Thank you for getting in touch.

Yes please provide me with the admin access to the site so that I can have a look at this for you.

Thanks,
Shane

#1596213

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Richard,

Thank you for the credentials.

I tried locating the code for the login but I can't seem to find it on your site.

Could you let me know exactly where it is ? It should also be noted that i'm not able to access the functions.php file for the site.

Thanks,
Shane

#1596347

Oh that makes sense, sorry about that.

I installed a file manager plugin, that will be easier than me setting up SFTP login. The code is located in the functions.php file of the OceanWP child theme. Starts on line 56.

#1596357

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screenshot 2020-04-22 at 3.21.50 PM.png

Hi Richard,

I checked the functions.php file and its not there.

Perhaps it was removed why it's not working ? Have a look at my screenshot of the functions.php file from the Astra Child theme.

Could you check on your end to see if the code is visible for you there.

Thanks,
Shane

#1596441

Oh shoot, haha, I changed themes a while back and didn't copy my functions over. That would explain it.

Is there a place I can/should store those kinds of functions so they work no matter which theme I use? Where would you recommend?

#1596449

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Richard,

Actually yes, I would recommend that you add this custom code to Toolset -> Settings -> Custom Code.

Once you've added the code remember to activate it.

Now if it is added here even if you change your theme the code will still work on your site.

Please let me know if this helps.
Thanks,
Shane

#1596555

Good to know, thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.