Skip Navigation

[Resolved] Keeping a new user signed in while completing a series of forms

This support ticket is created 2 years, 6 months 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)

This topic contains 2 replies, has 2 voices.

Last updated by lesleyA 2 years, 6 months ago.

Assisted by: Shane.

Author
Posts
#2375369
Screen Shot 2022-06-01 at 14.02.56.png

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?
hidden link

#2375467

Shane
Supporter

Languages: English (English )

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

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

#2375475

My issue is resolved now. Thank you!