- This topic has 16 replies, 7 voices, and was last updated 11 years, 2 months ago by
mary gallagher.
- AuthorPosts
- January 10, 2015 at 10:41 pm #10002981
daniel 2030ParticipantHello, Is it possible to auto login after registration?
January 12, 2015 at 3:05 pm #10002990
Pie RegisterParticipantHello,
I am afraid at the moment it’s not possible perhaps we will add this
feature in our future releases.Thanks
January 29, 2015 at 4:35 am #10003091
mary gallagherParticipantI agree that this is a needed feature. Many of my users – most not very used to on-line registrations – are completely flummoxed by having to login after registering. Auto login would be the expected UX behavior.
On the other hand, is there a hook that might be useful to accomplish this???
Thanks.January 30, 2015 at 1:57 am #10003094
mary gallagherParticipantI was just able to get automatic login by using the user_registration hook.
/* ——————————————————————-
Automatically login a user who has just registered. Pie-Register
does not currently support automatic login.
——————————————————————*/
function auto_login_new_user( $user_id ) {
$_SESSION[‘auto’] = $_POST;
wp_set_current_user($user_id);
wp_set_auth_cookie($user_id);
// wp_safe_redirect( home_url() ); OR…
wp_safe_redirect( home_url(‘/your-page/’) );
exit;
}
add_action( ‘user_register’, ‘auto_login_new_user’ );Hope this helpful to anyone looking for a solution. Cheers.
January 31, 2015 at 1:38 am #10003096
Fernando MoralesParticipantHi Mary, where do you put that hook? in index? or in all pages?
Thanks in advance
February 9, 2015 at 8:54 am #10003123
mary gallagherParticipantHi. I’m sorry to have to report that the hook does not work in one important respect. The registration function no longer add the first and last name of the registrant to the usermeta table. So, my form that should initialize the first name to [first_name} and last_name to [last_name] are blank. These are the only usermeta fields in my registration, but I also note that description, which I do not use, is not initialized. All the other standard usermeta fields are set.
I’ve tried setting lower and higher priorities, to no avail. I would certainly appreciate it if someone could suggest why this data is not being stored.
Fernando, the hook is placed in functions.php. However, I would not suggest using it until this is cleared up.
February 9, 2015 at 10:17 am #10003124
mary gallagherParticipantRemoving the exit statement appears to fix things although now I am not getting redirected to the correct page. I’m still investigating this. So, use with caution and test well!
function auto_login_new_user( $user_id ) {
wp_set_current_user($user_id);
wp_set_auth_cookie($user_id);
// wp_safe_redirect( home_url() ); OR…
wp_safe_redirect( home_url(‘/your-page/’) );
}
add_action( ‘user_register’, ‘auto_login_new_user’ , 10, 1);February 9, 2015 at 3:26 pm #10003130
Pie RegisterParticipantHello,
I’d suggest you to use Pie-Register Hook
pie_register_after_registerthis hook return User Object as defined in line # 1482 of pie_save_registration function.I hope it helps.
Thanks
May 15, 2015 at 11:54 am #10003465
gerard kilbirdeParticipantWould anybody expand on where to put this code to get it to work?
thanks again
May 15, 2015 at 3:04 pm #10003467
Pie RegisterParticipantThis is coming along with many other excited features in pro version soon!
- AuthorPosts
- The forum ‘Installation’ is closed to new topics and replies.
