Created
September 7, 2018 20:34
-
-
Save TheLastCicada/97d3fd6d66f0301691b8bce315aeeb60 to your computer and use it in GitHub Desktop.
Enhanced OneLogin Password Fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This script search user with @@@nopass@@@ passwords and replace them by random passwords | |
*/ | |
add_filter( 'send_password_change_email', '__return_false' ); | |
$users = get_users(); | |
foreach ($users as $user) { | |
$auth = wp_authenticate($user->user_login, '@@@nopass@@@'); | |
if (!is_wp_error($auth) ) { | |
$auth->user_pass = wp_generate_password(20, true); | |
wp_update_user($auth); | |
echo "User {$auth->ID} updated \n"; | |
} else { | |
echo "User {$user->ID} doesn't have the bad password \n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on https://gist.github.com/pitbulk/a8223c90a3534e9a7d5e0a93009a094f, this script should be put in the WordPress directory and executed using wp-cli with the command
wp eval-file fixpw.php
. Improvements over the original include: