WooCommerce Email Verification WordPress Code

Ok, i though this will be available since Woocommerce is pretty popular but HOW COME NO ONE ACTUALLY MAKE THIS CODE AND OPEN SOURCE IT?! Holy cow! I search it everywhere and couldn't find WooCommerce verifying user email before allowing the user to access WordPress without verifying whether their email is authentic. In the end i wrote it myself and i'm gonna throw it out for people to use.

11 thoughts on “WooCommerce Email Verification WordPress Code

  1. Hi Clay,

    That's work perfectly! That's what I'm looking for.

    Just one question, is that possible to redirect new user to their my account page without enter the login details once the user click on the activation link. (something like auto login after activation)

    please help

  2. yeah its possible, you'll just need to alter the verification section and add the following,

    wp_set_current_user ( $userID );
    wp_set_auth_cookie ( $userID );
    $url = "website account page";

    where $userId is the one you want it to be logged in and $url is your website account page

  3. This works well. First good opensource solution for a product that is so wildly used.

    The code sends the "Resend" email with activation link twice. Is there a way to fix this?


  4. disable the email send from this script and go to your WordPress theme and find the folder (or create a folder and file)


    and copy the logic of the activation into the above path and attached the link on this php script. When a user register, it will just send from the above template rather than sending the activation and new user registration email separately.

  5. Does it mean that I have to move my_user_register function completely in the new location and then use include to call that file?

    Just so that I'm clear, when the new user registers the first time the code only sends 1 email. It works fine. However if the users tries to login without activating, they get the message for "resend activation email". Upon clicking this the code sends 2 identical emails with same hash coded activation link in each email. The Two emails are sent at the same time.


  6. hmmm..it didn't happen on my Woocommerce installation though. For mine, it sends 2 email too, but one email from this article code and another email from the default new customer registration email. And since this is a problem, the emailing logic of the code provided here needs to move to the path i have just mention in my previous email and not moving the my_user_register function completely to the new location though.

    As for your problem, it seems like a complete different problem entirely, might be some plugin or logic you have added previous?

  7. Really thanks! It's work for me!
    And I recommend if you want a notice after registration
    wp_redirect( get_site_url(). '/my-account/?nt=yes');
    And in function my_init() add
    wc_add_notice( __( 'Success: Thank you for your registration. Please check your email to activate account! ', 'inkfool' ) );

  8. Great! Worked! But I receive to confirmation on the my account page after successful activation... I received this 2x "Success: Congratulations! Your account has been activated!"

    How can I correct this?


  9. Hmmmm... when I tried to refresh, eventhough I am already logged in, I still received this notice: "Error: Your account has to be activated before you can login. Please check your email." I am already inside my account but this notice still showed up after I refreshed the browser...

    How can we correct this? That there should no longer be any notices onced logged in...


  10. thanks guys, i found this very helpful, but i have issues, firstly:
    1. the validation hooks the already existing members, is there a way i can make the existing members login without having to validate?
    2. what do i do to enable auto login as the new user clicks the validation link.
    i would really appreciate guys..

  11. Hi! I pasted the code in the functions.php but I have a few problems. If I try to register as a user on my shop I do not receive the email with the activation code, nor the email that informs me that I have registered on the site. If I try to log in with that e-mail address, I get the message that my email is not activated. Any thoughts on why this is happening?

  12. Just un update... I have received the two emails that you have said in the comments... in my spam folder and after 2 hours. Do you happen to know why this has happened?

Comments are closed.