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.


1 Answer 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'].

  • Since they are new user's it should be possible to just use wp_generate_password().
    – wyrfel
    Commented Feb 24, 2011 at 20:15
  • 4
    thats probably a better idea. I managed to get this working without the users password using wp_set_auth_cookie which only requires the user ID. Commented Feb 25, 2011 at 6:57
  • Re: innate's comment on wp_set_auth_cookie see this post: wordpress.stackexchange.com/a/53505/7772 Commented Sep 10, 2012 at 8:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.