• Resolved Keith Manning

    (@keithp4)


    Absolutely LOVE this plugin. It’s the only one I’ve found that does all the registration and login functionality that I need. And the ability to create/use custom fields makes it ever sweeter. I do plan on purchasing the PRO version, but I have a question for you….

    Whenever someone tries to register or login, I need to run some code that looks in another database to verify that the email address exists there. If that email address doesn’t exist, then I need to cancel and disallow the registration or login.

    I need to run this code AFTER the registration and login form is submitted but BEFORE the user is added to the Users table and BEFORE the user logs in. Can you tell me what hooks that I can use for this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Keith Manning

    (@keithp4)

    I found your documentation on hooks which is very helpful, but any insight you can give would be great, as I’m still learning how to use WP hooks.

    I want to use your email verification when a user registers, so my workflow should be like this:

    1. User submits USER META registration form (email and password)
    2. Use hook to run custom PHP code to validate user email address
    3. USER META sends verification email to user
    4. User clicks link to verify email

    I just need to know what hook to use to run the custom code in step #2… after the registration form is submitted but before the verification email is sent out.

    • This reply was modified 2 years, 9 months ago by Keith Manning.
    Plugin Author Sourov Amin

    (@sourov)

    Hi,

    You can use user_meta_pre_user_register hook for your specific issue.
    A script like the below should work.

    add_filter('user_meta_pre_user_register', 'userDataCheck');
    function userDataCheck($userData){
        // connect your email list
        $emailList = array('[email protected]', '[email protected]');
    
        if (!empty($userData['user_email'])) {
            // check if the user provided email on the list, otherwise throw error
            if (!in_array($userData['user_email'], $emailList)) {
                return new \WP_Error('invalid', 'Not a valid email');
            }
            return $userData;
        }
    }

    Let me know if you face any problems figuring this out.

    Thanks!

    Thread Starter Keith Manning

    (@keithp4)

    Works great. Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hooks to run some code BEFORE registration and login’ is closed to new replies.