Code
add_action( 'cred_save_data', 'cred_autologin_V2', 10, 3 );
function cred_autologin_V2( $post_id, $form_data ){
if ( 1 == $form_data['id'] || 2 == $form_data['id'] || 3 == $form_data['id'] ) { // Edit as required
if ( !empty( $_REQUEST['user_email'] ) && !empty( $_REQUEST['user_pass'] ) ) {
// get the user credentials from the $_POST object
$user = array(
'user_login' => substr( $_REQUEST['user_email'], 0, strpos( $_REQUEST['user_email'], "@")),
'user_password' => $_REQUEST['user_pass'],
'remember' => true
);
$login = wp_signon( $user, false );
if ( is_wp_error($login) ) {
error_log('error during auto login, user_login was: ' . substr( $_REQUEST['user_email'], 0, strpos( $_REQUEST['user_email'], "@")));
error_log( $login->get_error_message() );
}
}
}
}
This was working until last night and now the user registers but does not get logged in, what could I be missing?
Form code:
[creduserform]
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
[cred_field field='form_messages' class='alert alert-warning']
</div>
</div>
<div class="row">
<div class="form-group col-md-6">
<label>[cred_i18n name='first_name-label']First name[/cred_i18n]</label>
[cred_field field='first_name' class='form-control' output='bootstrap']
</div>
<div class="form-group col-md-6">
<label>[cred_i18n name='last_name-label']Last name[/cred_i18n]</label>
[cred_field field='last_name' class='form-control' output='bootstrap']
</div>
</div>
<div class="row">
<div class="form-group col-md-12">
<label>[cred_i18n name='user_email-label']Email[/cred_i18n]</label>
[cred_field field='user_email' class='form-control' output='bootstrap']
</div>
</div>
<div class="row">
<div class="form-group col-md-12">
<label>[cred_i18n name='user_pass-label']Password[/cred_i18n]</label>
[cred_field field='user_pass' class='form-control' output='bootstrap']
</div>
</div>
<div class="row">
<div class="col-md-12">
[cred_field field='form_submit' output='bootstrap' value='Get Started For Free' class='btn btn-primary btn-lg toolset-home-v2']
</div>
</div>
<br>
</div>
[/creduserform]
I have also look at the server error log and found nothing related to this
2022-06-23 17:18:41 UTC [apache][autoindex:error] [pid 64628] [client 66.249.70.17:12136] AH01276: Cannot serve directory /home/customer/www/domain/public_html/wp-content/plugins/wpdatatables/assets/js/wpdatatables/: No matching DirectoryIndex (index.html,Index.html,index.shtml,index.php,Index.php,index.phtml,Index.phtml,index.htm,Index.htm,home.htm,Home.htm,Default.htm,Default.html,default.htm,default.html) found, and server-generated directory index forbidden by Options directive
2022-06-23 16:41:39 UTC [nginx][error] 55446#0: *7796941 openat() "/home/u2-egtifjgmwrwx/www/domain/public_html/.well-known/assetlinks.json" failed (2: No such file or directory), client: 66.249.70.8, server: domain, request: "GET /.well-known/assetlinks.json HTTP/1.1", host: "www.domain"