我正在使用Wordpress的内置忘记密码重置表单和视图。
我想限制重设密码的次数电子邮件尝试。默认情况下,Wordpress允许您发送无限的重置密码电子邮件,我想设置一个限制。我该怎么做?
此功能仅在Wordfence安全插件中可用。我不想用Wordfence。我寻找其他插件,但找不到。我真的可以写代码。你可以写个建议。
发布于 2020-09-07 13:35:17
您需要将尝试放在用户元上,然后每次用户点击重置密码时都要检查。
add_action( 'password_reset', 'my_password_reset', 10, 2 );
function my_password_reset( $user, $new_pass ) {
$limit=5;// Set the limit here
$attempts=(int) get_user_meta($user->ID,"reset_attempts",true);
if($attempts>$limit){
//Do something in here, example redirect to warning page.
wp_redirect( "/warning" );
exit;
}
update_user_meta($user->ID,"reset_attempts",$attempts++);
}https://wordpress.stackexchange.com/questions/374397
复制相似问题