Posted By

oriontimbers on 09/03/10


Tagged

login wordpress register auto


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

Jamie
mfgalex
booski
diegotrap


WordPress AutoLogin


 / Published in: PHP
 

Code snippet that allows the user to be automatically logged in on account creation, this works with s2Member since they allow the user to create their own password.

  1. function auto_login($userID) {
  2. if (!is_user_logged_in()) {
  3.  
  4. $user = get_userdata($userID);
  5. $user_id = $user->ID;
  6. $user_login = $user->user_login;
  7.  
  8. //login
  9. wp_set_current_user($user_id, $user_login);
  10. wp_set_auth_cookie($user_id);
  11. do_action('wp_login', $user_login);
  12. }
  13. }
  14. add_action('user_register', 'auto_login');

Report this snippet  

You need to login to post a comment.