Hello. Thank you for contacting the Toolset support.
I checked on your install and yes I confirm that the code you added with the help of Toolset form API hook cred_save_data for autologin the user is not working.
But the strange thing is that the same code I've added with my test site where I tried to create a user with the same subscriber role using Toolset form and it works without any issue on my test site.
You can create a new user with my test site using the following link: versteckter Link
- As soon as you create new user, it will be redirected to home page and it will autologin as well.
If you want backend access, you can use: versteckter Link
User: demo
pass: Admin@123
I've used the following code - which is added to "Custom Code" section of Toolset:
=> versteckter Link
add_action( 'cred_save_data', 'func_tssupp_cred_autologin', 10, 2);
function func_tssupp_cred_autologin( $post_id, $form_data ){
if ( $form_data['id'] == 1708 ) { // Edit as required
if ( !empty( $_POST['user_email'] ) && !empty( $_POST['user_pass'] ) ) {
$user = get_user_by( "email", $_POST['user_email'] );
// get the user credentials from the $_POST object
$user = array(
'user_login' => $user->user_login,
'user_password' => $_POST['user_pass'],
'remember' => true
);
$login = wp_signon( $user, false );
if ( is_wp_error($login) ) {
error_log( $login->get_error_message() );
}
}
}
}
As its working with the minimum setup where only Toolset plugins installed with the default theme, I suggest in order to minimize the cause of the issue:
Could you please try to resolve your issue by deactivating all third-party plugins as well as the default theme to check for any possible conflicts with any of the plugins or themes?
- Do you see any difference or found plugin/theme is causing the issue?
Thanks so much for your help with this. Have already tried disabling all plugins to no avail. I'm going to use your code and give it ago, will update shortly.
Ok fine - As I shared the link to my test site, it works as expected so there must be something going on with third-party plugin/theme or server. You need to check where the issue is.