Send activation link to user after registration in WordPress

I am using custom user registration and log in in WordPress. Now I want to send a mail containing activation link to the registered user so that they can complete their registration after clicking that link.

Related posts

Leave a Reply

2 comments

  1. You can do it something like by adding this code in fucntions.php your send_activation_link() functon in
    add_action ( 'user_register', 'send_activation_link');

    user_register is a hook, which runs at the end of user creation

    function send_activation_link(){
    $hash = md5( $random_number );
    add_user_meta( $user_id, 'hash', $hash );
    $user_info = get_userdata($user_id);
    $to = $user_info->user_email;           
    $subject = 'Member Verification'; 
    $message = 'Hello,';
    $message .= "nn";
    $message .= 'Welcome...';
    $message .= "nn";
    $message .= 'Username: '.$un;
    $message .= "n";
    $message .= 'Password: '.$pw;
    $message .= "nn";
    $message .= 'Please click this link to activate your account:';
    $message .= home_url('/').'activate?id='.$un.'&key='.$hash;
    $headers = 'From: noreply@test.com' . "rn";           
    wp_mail($to, $subject, $message, $headers); 
    }
    

    Its not a complete answer but just to give an idea to work something like this