Skip to content

Instantly share code, notes, and snippets.

@WPAcademic
Created July 17, 2020 14:52
Show Gist options
  • Save WPAcademic/1f507ffa66d94de2c26a3356d5edbf09 to your computer and use it in GitHub Desktop.
Save WPAcademic/1f507ffa66d94de2c26a3356d5edbf09 to your computer and use it in GitHub Desktop.
Reset WordPress Password From Username
add_action('init', function() {
$userName = 'admin';
$passwordToSet = 'testing';
$userObj = get_user_by('login', $userName);
// $userEmail = 'user@example.com';
// $userObj = get_user_by( 'email', $userEmail );
if($userObj) {
$userID = $userObj->ID;
wp_set_password($passwordToSet, $userID);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment