Send activation link to user after registration in WordPress

20,328

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 .= "\n\n";
$message .= 'Welcome...';
$message .= "\n\n";
$message .= 'Username: '.$un;
$message .= "\n";
$message .= 'Password: '.$pw;
$message .= "\n\n";
$message .= 'Please click this link to activate your account:';
$message .= home_url('/').'activate?id='.$un.'&key='.$hash;
$headers = 'From: [email protected]' . "\r\n";           
wp_mail($to, $subject, $message, $headers); 
}

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

Share:
20,328
Sujeet Kumar
Author by

Sujeet Kumar

Thank you for visiting my profile. I am a full-stack web/mobile application developer from New Delhi, India. I has been developing and designing Web/mobile Applications using PHP, MySQL, MVC, Codeigniter, Wordpress, PHPBB, Woocommerce, CSS3, Bootstrap, JavaScript, JQuery, HTML5, Angular, JQuery Mobile, Onsen, Cordova/Phonegap and other Open Source programming for 5+ years and Yes my Web/mobile apps are delightful on any device. Visit my Linkedin Profile

Updated on September 11, 2020

Comments

  • Sujeet Kumar
    Sujeet Kumar almost 4 years

    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.