如何从WordPress删除密码重置/更改选项

Are you looking to remove the password reset option in WordPress? By default, WordPress allows users to reset/change password by providing their email address. Sometimes you may want to disable password reset option in WordPress. In this article, we will show you how to remove the password reset / change option from WordPress.

您是否要删除WordPress中的密码重置选项? 默认情况下,WordPress允许用户通过提供其电子邮件地址来重置/更改密码。 有时您可能要禁用WordPress中的密码重置选项。 在本文中,我们将向您展示如何从WordPress中删除密码重置/更改选项。

Removing password reset option from WordPress
为什么要从WordPress删除密码重置/更改选项 (Why Remove Password Reset/Change Option From WordPress)

If you allow user registration on your WordPress site, then password reset option allows user to recover lost passwords. Normally, you wouldn’t want to change that.

如果您允许用户在WordPress网站上注册 ,则密码重置选项允许用户恢复丢失的密码 。 通常,您不需要更改该设置。

However, in some usage scenarios you may want to remove this option for specific users or user roles on your WordPress site.

但是,在某些使用情况下,您可能希望针对WordPress网站上的特定用户或用户角色删除此选项。

For example, if you have created a temporary account for someone or if you have created a demo site where users can login with a demo username and password.

例如,如果您为某人创建了一个临时帐户,或者您创建了一个演示站点,用户可以在其中使用演示用户名和密码登录。

The easier solution will be to just remove the password reset link. But some savvy users may already know the URL to access the password reset form.

较简单的解决方案是仅删除密码重置链接。 但是一些精明的用户可能已经知道访问密码重置表单的URL。

Having said that, let’s see how you can easily remove password reset/change option from WordPress.

话虽如此,让我们看看如何轻松地从WordPress删除密码重置/更改选项。

方法1:禁用使用插件的密码重置/更改选项 (Method 1: Disable Password Reset/Change Option Using Plugin)

The plugin method is better and easier. It allows you to disable password reset option for specific user roles or even individual users.

插件方法越来越好。 它允许您禁用特定用户角色甚至单个用户的密码重置选项。

This way you can still control and provide password reset feature for some trusted users or user roles.

这样,您仍然可以控制某些受信任的用户或用户角色并提供密码重置功能。

First thing you need to do is install and activate the Plainview Protect Passwords plugin. For more details, see our step by step guide on how to install a WordPress plugin.

您需要做的第一件事是安装并激活Plainview Protect Passwords插件。 有关更多详细信息,请参阅有关如何安装WordPress插件的分步指南。

Upon activation, you need to visit Settings » Protect Passwords page to configure the plugin settings.

激活后,您需要访问设置»保护密码页面来配置插件设置。

Protect password settings

Simply select the user roles or individual users to disable their password change or reset option.

只需选择用户角色或单个用户即可禁用其密码更改或重置选项。

There is also an option to exempt individual users. This option is useful if you want to disable password reset option for all users except yourself.

还有一个免除个人用户的选项。 如果要禁用除您自己以外的所有用户的密码重置选项,此选项很有用。

Don’t forget to click on the save changes button to store your settings.

不要忘记单击“保存更改”按钮来存储您的设置。

You can see the plugin in action by visiting the WordPress login page and clicking on ‘Lost your password?’ link. It will take you to the password reset page where you can try entering the username or email address for a user who does not have password reset option.

您可以通过访问WordPress登录页面并单击“丢失密码?”来查看该插件的运行情况。 链接。 它将带您到密码重设页面,您可以在其中尝试输入没有密码重设选项的用户的用户名或电子邮件地址。

You will see an error indicating that password reset is not allowed for this user.

您将看到一个错误,指示不允许该用户重置密码。

Password reset disabled for this user
方法2:从WordPress手动禁用密码重置选项 (Method 2: Manually Disable Password Reset Option From WordPress)

This method requires you to add code to your WordPress site. It is not recommended for beginner level users.

此方法要求您将代码添加到WordPress网站。 不建议初学者使用。

First thing you need to do is open a blank text file using a text editor like Notepad. Paste the following code inside this file.

您需要做的第一件事是使用记事本之类的文本编辑器打开一个空白文本文件。 将以下代码粘贴到该文件中。


<?php
/*
 * Plugin Name: Disable Password Reset
 * Description: Disable password reset functionality. Only users with administrator role will be able to change passwords from inside admin area. 
 * Version: 1.0
 * Author: WPBeginner
 * Author URI: http://wpbeginner.com
 */
 
class Password_Reset_Removed
{

  function __construct() 
  {
    add_filter( 'show_password_fields', array( $this, 'disable' ) );
    add_filter( 'allow_password_reset', array( $this, 'disable' ) );
    add_filter( 'gettext',              array( $this, 'remove' ) );
  }

  function disable() 
  {
    if ( is_admin() ) {
      $userdata = wp_get_current_user();
      $user = new WP_User($userdata->ID);
      if ( !empty( $user->roles ) && is_array( $user->roles ) && $user->roles[0] == 'administrator' )
        return true;
    }
    return false;
  }

  function remove($text) 
  {
    return str_replace( array('Lost your password?', 'Lost your password'), '', trim($text, '?') ); 
  }
}

$pass_reset_removed = new Password_Reset_Removed();
?>

Save this file as disable-password-reset.php on your desktop.

将此文件另存为桌面上的disable-password-reset.php

Now you need to upload this file to your WordPress site. You will need an FTP client to do that. See our guide on how to use FTP to upload WordPress files.

现在,您需要将此文件上传到WordPress网站。 您将需要一个FTP客户端来执行此操作。 请参阅我们的指南, 了解如何使用FTP上传WordPress文件

Connect to your website using the FTP client and then go to the plugins folder. The plugin’s folder is located inside /wp-content/ directory.

使用FTP客户端连接到您的网站,然后转到plugins文件夹。 插件的文件夹位于/ wp-content /目录中。

Plugins folder on a WordPress site

Upload disable-password-reset.php file from your computer to the plugins folder on your WordPress site.

将您的计算机上的disable-password-reset.php文件上传到WordPress网站上的plugins文件夹。

Now you need to login to your WordPress admin area and visit the plugins page. You will notice a new plugin titled ‘Disable Password Reset’ in your list of installed plugins. Click on the activate link below the plugin.

现在,您需要登录到WordPress管理区域并访问插件页面。 您会在已安装的插件列表中注意到一个名为“禁用密码重置”的新插件。 单击插件下方的激活链接。

Activate Disable Password Reset plugin

That’s all, activating the plugin will disable password reset option for all users including administrators. Administrators will be able to change passwords from the admin area, but they will not be able to reset password from the login screen.

就这样,激活插件将对所有用户(包括管理员)禁用密码重置选项。 管理员将能够从管理区域更改密码,但是他们将无法从登录屏幕重置密码。

We hope this article helped you learn how to remove the password reset/change option from WordPress. You may also want to see our list of 13 plugins and tips to improve WordPress admin area.

我们希望本文能帮助您学习如何从WordPress中删除密码重置/更改选项。 您可能还想查看我们的13个插件列表和改善WordPress管理区域的提示

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-remove-the-password-reset-change-option-from-wordpress/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值