• Hi everybody,

    my question is simple, also the solution seems simple but i can’t get it to work.

    How can you log in a user automatically? In my plugin the user is logged in and is changing the password. Once the password is changed i want to keep the user logged in but with the new credentials. Instead it’s immediately logged out.

    This is the code i am using. I expected it to work but when i refresh the page it’s automatically logged out, always:

    —–
    $user = get_userdatabylogin($current_user->user_login);
    wp_set_password($new_pwd, $user->ID);

    wp_set_current_user($user->ID, $user->user_login);
    wp_set_auth_cookie($user->ID, 3600);
    do_action(‘wp_login’, $user->user_login);

    —–

    Thank you, it’s driving me crazy!!

  • The topic ‘Auto log in a user’ is closed to new replies.