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.
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
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
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.
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
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
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?
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