/ 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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function auto_login($userID) { if (!is_user_logged_in()) { $user = get_userdata($userID); $user_id = $user->ID; $user_login = $user->user_login; //login wp_set_current_user($user_id, $user_login); wp_set_auth_cookie($user_id); do_action('wp_login', $user_login); } } add_action('user_register', 'auto_login');
Comments
