用户需要通过单击电子邮件发送的链接来验证其电子邮件。链接如下:
http://www.example.com/wp-login.php?token=afdsDEDFdfsSE234&user_id=13
我用过
wp_authenticate 钩子以验证用户的令牌:
add_action( \'wp_authenticate\', array($this, \'verify_token\'), 30, 2);
和回调函数:
public function verify_token()
{
$user_token = afdsDEDFdfsSE234;
if($user_token == $_GET[\'token\'])
{
apply_filters( \'login_message\', __(\'Token mathed. Now login!\',\'user-registration\'));
}
}
SO网友:Agustin Prosperi
伙计,你真的需要看看hooks的文件https://codex.wordpress.org/Plugin_API/Action_Reference/wp_authenticatehttps://codex.wordpress.org/Plugin_API/Filter_Reference/login_message
Wp\\u authenticate接收一个参数,也接收login\\u消息,但不是apply\\u filter,而是需要使用add\\u filter来显示如下消息:
add_action( \'wp_authenticate\', array($this, \'verify_token\'), 30, 1);
// even if you aren\'t using the $username you need to declare it in the function
public function verify_token($username){
$user_token = afdsDEDFdfsSE234;
if($user_token == $_GET[\'token\']){
// the filters always return a value and receive at least one
add_filter( \'login_message\', function($message){
return __(\'Token mathed. Now login!\',\'user-registration\');
});
}
}
在使用你不知道的钩子之前,阅读文档,它们甚至有代码示例。