Affichage des articles dont le libellé est Password. Afficher tous les articles
Affichage des articles dont le libellé est Password. Afficher tous les articles

samedi 12 novembre 2016

How to Remove the Password Reset / Change option from 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.


Removing password reset option from 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.


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


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.


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


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.


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.


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


Password reset disabled for this user


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.


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.


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.


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.


Plugins folder on a WordPress site


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


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.


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.


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.


The post How to Remove the Password Reset / Change option from WordPress appeared first on WPBeginner.







How to Reset WordPress Admin Password on Localhost



Recently, one of our users asked us how to reset WordPress admin password on localhost? If you are running WordPress on localhost and forget your password, then you can’t reset it by email. In this article, we will show you how to reset WordPress admin password on localhost.


How to reset WordPress admin password on localhost


Why Password Reset Doesn’t Work on Localhost?


The term localhost is used to describe a local server that is not available to the general public. For example: your personal computer.


Many WordPress users install WordPress on localhost (in their computer) to test changes, design websites, try out new plugins, and even learn WordPress.


If you haven’t tried it, then see our tutorial on how to install WordPress on your Windows computer using WAMP.


Mac users can follow instructions in our tutorial on how to install WordPress locally on Mac using MAMP.


Now here is the problem that some beginners may come across.


If you forget your WordPress admin password while working on localhost, then you will be NOT be able to reset it using the normal password reset option in WordPress.


The password reset option emails you a link to reset your WordPress password. In order to send emails, your server needs to enable the mail function.


This function is turned off by default on local servers which means WordPress will not be able to send the password reset email.


But don’t worry, there’s a way to reset your WordPress password on localhost.


Ready? Let’s get started.


Reset WordPress Admin Password on Localhost


We will be using phpMyAdmin to reset password on localhost. Simply visit phpMyAdmin control panel by typing this URL in your browser’s address bar:


http://localhost/phpmyadmin/


You will be asked to provide your MySQL username and password. Typically, the username is root with no password.


Once you are logged in, you need to select your WordPress database.


Select database


Once you select your database, you will see a list of tables in your WordPress database. Go ahead and click on the browse link next to WordPress users table.


Users table in WordPress database


You will now see the list of entries in your users table. The number of rows depend on how many users are registered on your WordPress site.


Next, you need to click on the Edit link next to the username of the admin user.


Browsing users table in WordPress DB


This will open up a form where you can edit the information stored in WordPress database for that user.


Changing user password


Scroll down to user_pass field and type a new password in the ‘value’ column. After that you need to select MD5 in the ‘function’ column.


Don’t forget to click on the Go button at the bottom to save your changes.


That’s all, you can now login to your WordPress site on localhost using the new password.


If for some reason you’re having a hard time following the phpMyAdmin method, then please look at our guide on how to create a WordPress admin user using your functions.php file. Simply open your theme’s functions.php file and paste the code in the article above, and you’ll be good to go.


We hope this article, helped you learn how to reset WordPress admin password on localhost. You may also want to see our guide on how to how to move WordPress from local server to live site.


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.


The post How to Reset WordPress Admin Password on Localhost appeared first on WPBeginner.