Validate Existing users email

Home Forums Feature Requests Validate Existing users email

This topic contains 4 replies, has 2 voices, and was last updated by  James Lukensow 4 years ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #7703

    I have this strange request from the client. They want to validate all users every 6 months. So what I’m thinking, is create a cron job to query for all “subscribers” and send a validate email. They will stay Pending, until they click the link, at which point they can continue to use the site.

    I’m more than comfortable developing this within User Meta. My question is, where is a good place to start within this plugin, is there any methods / functions already for this? Maybe to take a use who is activated and set them Pending, initiate the email, etc?

    Thanks,

    James

    #7708

    Khaled
    Keymaster

    Hi James,

    Here is an example to deactivate a user and sending deactivation email.

    function userDeactivateAndSendEmail($userID)
    {
        global $userMeta;
    
        // Deactivate user. you can also use 'pending'
        update_user_meta($userID, 'user_meta_user_status', 'inactive');
    
        // Sending deactivation email.
        $user = new WP_User($userID);
        $userMeta->prepareEmail('deactivation', $user);
    }
    

    Hope, it helps.

    Thanks.

    #7709

    Khaled
    Keymaster

    To get email verification link, call following function:

    global $userMeta;
    $user = new WP_User($userID);
    $url = $userMeta->emailVerificationUrl($user);
    
    #7710

    This is great and exactly what I needed, thank you!

    #7718

    Another question, is their a datetime of when the activation link was clicked? Or when the account was activated?

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.