5

I have set up the registration form using this chunk of code:

wp_create_user($username, $password, $email);

Note that i have did all kinds of validation before use this code. The registration is working fine now. But it register and activate the user account immediately after the form get submitted.

What i want is confirming the email of a user before they can use the account. User have to check there email account and click the confirmation link and user account get registered/active.

1 Answer 1

5

I had to implement this for a client site and ended up creating my own system.

I hash the email and date created timestamp and store it as a key in usermeta, then i email that key to the user's email in the form of a link. The link points to a page where I've created a rewrite rule and added my own query var so I can make nice site.com/authorize/{key} links.

When they click through the link, I look up the matching user with that key and delete the key so they can now log in. I actually also log them in right there with wp_signon and use wp_redirect to send them to a welcome page.

On my custom login form I check if the key has been deleted for a user before letting them log in.

There may be a plugin to enable this same process, or perhaps some of it can be achieved via hooks where I've just rewritten it, I'm not sure, I didn't explore doing it that way because of additional unique requirements for this particular project.

5
  • thanks for the answer. When wordpress registration is open how does wordpress handle the situation? Isn't it send a confirmation email?
    – Sisir
    Commented Aug 23, 2011 at 16:33
  • It creates the password for you, so you can't log in without getting the password from your email. I had to make the system allow the user to create their own password but not let them log in until they clicked the link.
    – Milo
    Commented Aug 23, 2011 at 16:41
  • I see what you mean now! Wordpress really need to improve this! I will try to make it of my own. Will let you know if i get stuck. Thanks!
    – Sisir
    Commented Aug 23, 2011 at 16:54
  • Here is my plan. I will create a inactive user table and a registration key that will be stored in the table with user other info. After user confirming the email i will move the user from inactive user table to wordpress user table. I also have to remove any user that did not confirm email in 24 or 48 hours. So i might need to use cron jobs? What is your advice?
    – Sisir
    Commented Aug 23, 2011 at 17:03
  • @Sisir Wp cron & transients (there's an API) only update when a user visits the page/makes a request. So imo it's better to also store some sort of option where you additionally hold some id or similar.
    – kaiser
    Commented Aug 23, 2011 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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