Skip Navigation

[Resolved] User is registered, but not logged in

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 1 reply, has 1 voice.

Last updated by georgiI 10 hours, 22 minutes ago.

Assisted by: Minesh.

Author
Posts
#2818444

I had no problem until now.
But today when i registered a user trough a custom user form, that worked perfectly before, they no longer log in.

After the registration, they are redirected to a page, but does not show they've logged in. I have forms/elements etc. that hide for logged-in users, and i thought the registration did not happened, but when i tried registering with the same credentials i got an error saying the user exists.

What could be the cause of that? They have no problem logging in trough elementor form.

#2818525

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share exact requirement first.

Do you want that you have user registration form and once user is registered you want to auto-login the user and redirect to x page?

#2818535

I found a solution on my own and am sharing it here, since the threads with code no longer work

add_action('cred_save_data', 'auto_login_after_selected_forms', 10, 2);
function auto_login_after_selected_forms($user_id, $form_data) {
// List the IDs of the forms where auto-login should happen
$auto_login_form_ids = array(653, 1231); // Replace with your actual form IDs

if (in_array($form_data['id'], $auto_login_form_ids)) {
wp_set_current_user($user_id);
wp_set_auth_cookie($user_id);
do_action('wp_login', get_userdata($user_id)->user_login, get_userdata($user_id));
}
}

Where replace the ids of all forms by comma in (653, 1231);