authenticate user without password from email activation link

I have my own activation mail for new users that are added via a plugin in the wp backend by an admin. The user is also added as an author to a post and I want him to activate the post (which will publish it) when he gets the email and clicks the link. Currently, the user receives an email with an activation link, but then has to log in and is not redirected to the activation screen. Is it possibly to authenticate the user by receiving the activation key and post id via the URL? The key is stored in his post as a custom field. I basically want this process to log him in automatically and allow him to access hist post from a front end page.

Related posts

Leave a Reply

1 comment

  1. To login a user progrmaticly you can use:

        //Login the user
    $creds = array();
    $creds['user_login'] = $login;
    $creds['user_password'] = $password;
    if ( !empty( $remember ) ){ 
        $creds['remember'] = true;
    }
    $user = wp_signon( $creds, true );
    

    but as you can see you will need to have the password present , so you can just add to your actovation url &pw=pasword and call it using $_GET[‘pw’].