Replies: 0
I’m using these two functions as outlined in the WP Codex to programmatically login users for a sort of SSO for a client site. But it is not actually logging them in. The return value of wp_set_current_user() is a correct WP_User object. But nothing actually changes on the front end.
if ( !is_user_logged_in() ) {
$user_login = 'kayla';
$user = get_user_by( 'slug', $user_login );
$user_id = $user->ID;
wp_set_current_user($user_id, $user_login);
wp_set_auth_cookie($user_id);
do_action('wp_login', $user_login, $user, false);
}
Above is a chunk of my code I’m using to login the user after they’ve been validated. It’s exactly as the documentation states. What is wrong?