简体   繁体   English

在WordPress中注册后向用户发送激活链接

[英]Send activation link to user after registration in WordPress

I am using custom user registration and log in in WordPress . 我正在使用自定义用户注册并登录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. 现在,我想向注册用户发送包含激活链接的邮件,以便他们在单击该链接后可以完成注册。

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'); 您可以通过在fucntions.php中的add_action ( 'user_register', 'send_activation_link'); send_activation_link()函数中添加此代码来完成此操作add_action ( 'user_register', 'send_activation_link');

user_register is a hook, which runs at the end of user creation user_register是一个挂钩,在用户创建结束时运行

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: noreply@test.com' . "\r\n";           
wp_mail($to, $subject, $message, $headers); 
}

Its not a complete answer but just to give an idea to work something like this 这不是一个完整的答案,而只是给出一个想法来像这样工作

You can use "User Activation E-mail" Wordpress plugin to do that. 您可以使用“用户激活电子邮件” Wordpress插件来执行此操作。

Here is the link: http://wordpress.org/plugins/user-activation-email/ 这是链接: http : //wordpress.org/plugins/user-activation-email/

用户如何激活帐户

I hope this will help you! 我希望这能帮到您!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM