在某些特殊情况下,可能需要禁止用户使用WordPress自带的密码重置功能,也就是在登录界面点击“忘记密码?”来找回密码:

如果要禁止所有用户使用这个功能,可以在主题的 functions.php 添加下面的代码:
add_filter('allow_password_reset', '__return_false' ); |
add_filter('allow_password_reset', '__return_false' );
如果仅仅是禁止某些特定的用户使用这个功能,可以在主题的 functions.php 添加下面的代码:
add_filter('allow_password_reset', 'no_reset', 10, 2 );
function no_reset( $bool, $user_id ) {
$ids = array( 3, 10 ); // 要禁止的用户ID
if ( in_array( $user_id, $ids ) )
return false;
return true;
} |
add_filter('allow_password_reset', 'no_reset', 10, 2 );
function no_reset( $bool, $user_id ) {
$ids = array( 3, 10 ); // 要禁止的用户ID
if ( in_array( $user_id, $ids ) )
return false;
return true;
}
如果你想禁止用户在“我的个人资料”中修改密码,可以参考 WordPress 禁止用户编辑“我的个人资料”的电子邮件等字段
来源:
https://www.wpdaxue.com/disallow-password-resets.html
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_33165.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57