Tell us what you are trying to do?
I have a sign up process which involves a number of forms.
To begin with, guest fill a user form which then directs to a post form.
I have added this code to keep the new user logged in:
add_action( 'cred_save_data', 'tssupp_cred_autologin', 10, 2 );
function tssupp_cred_autologin( $post_id, $form_data ){
if ( 2177, 1521 == $form_data['id'] ) { // Edit as required
if ( !empty( $_POST['user_login'] ) && !empty( $_POST['user_pass'] ) ) {
// get the user credentials from the $_POST object
$user = array(
'user_login' => $_POST['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() );
}
}
}
}
It did work, but somehow it has stopped working. I've checked the two form IDs and they are correct.
I've attached a screen grab which shows the error.
Is there any documentation that you are following?
Is there a similar example that we can see?
What is the link to your site?
enlace oculto
Hi Lesley,
There are some errors in your code. Can you replace this line below .
if ( 2177, 1521 == $form_data['id'] )
with
$arr= array(2177,1521);
if ( in_array($form_data['id'],$arr))
Please try this and let me know if you code works now.
Thanks,
Shane
My issue is resolved now. Thank you!