Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
Innate: Thank you! You saved me some nerves. – user3819 Mar 9 '11 at 12:33

1 Answer

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

share|improve this answer
Since they are new user's it should be possible to just use wp_generate_password(). – wyrfel Feb 24 '11 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. – Innate Feb 25 '11 at 6:57
Re: innate's comment on wp_set_auth_cookie see this post: wordpress.stackexchange.com/a/53505/7772 – Nick Budden Sep 10 '12 at 8:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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