Group Password Reset in WordPress

I recently had some trouble when I couldn’t regain access to this site. I tried the email reset and manual resetting the password in the database but neither seem to work. Rather than doing anything about it I kind of just lost interest and went on working with other projects (something a 30 second Google would have fixed). It was only the other day when a client requested I update a number of passwords bulk that I realised how easy it is to change a password at the script level and that I could apply that to my own problem.

Here is the quick process I used to reset the password for all users of the same role.

	require('../wp-load.php' );

	global $wpdb;

	$subscriber = $wpdb->get_results( "SELECT * FROM `wp_usermeta` WHERE `meta_value` LIKE 'a:1:{s:10:\"subscriber\";s:1:\"1\";}'" );

	foreach($subscriber AS $s) {
		wp_set_password('PASS1234', $s->user_id);

Obviously I would never suggest giving all your users the same password, but this was specifically requested by the client and the members area doesn’t truly hold any secret information. The most important things to note here are the use of wp-load.php (the quickest method to access the WordPress database) and wp_set_password(). Also note that I didn’t use the password PASS1234.

So to reset my admin password was even simpler. Again not my real password.

	require('wp-load.php' );

	wp_set_password('password1234', 1);

– Morgan Leek