Switch to *_user_option() for default password nag to avoid extra DB queries. Fixes #11380
git-svn-id: https://develop.svn.wordpress.org/trunk@12983 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
8b38dceeca
commit
8fbe3333b0
@ -64,7 +64,7 @@ function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated
|
|||||||
$random_password = wp_generate_password();
|
$random_password = wp_generate_password();
|
||||||
$message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
|
$message = __('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you.');
|
||||||
$user_id = wp_create_user($user_name, $random_password, $user_email);
|
$user_id = wp_create_user($user_name, $random_password, $user_email);
|
||||||
update_usermeta($user_id, 'default_password_nag', true);
|
update_user_option($user_id, 'default_password_nag', true, true);
|
||||||
} else {
|
} else {
|
||||||
$random_password = '';
|
$random_password = '';
|
||||||
$message = __('User already exists. Password inherited.');
|
$message = __('User already exists. Password inherited.');
|
||||||
|
@ -807,34 +807,33 @@ endif;
|
|||||||
add_action('admin_init', 'default_password_nag_handler');
|
add_action('admin_init', 'default_password_nag_handler');
|
||||||
function default_password_nag_handler($errors = false) {
|
function default_password_nag_handler($errors = false) {
|
||||||
global $user_ID;
|
global $user_ID;
|
||||||
if ( ! get_usermeta($user_ID, 'default_password_nag') ) //Short circuit it.
|
if ( ! get_user_option('default_password_nag') ) //Short circuit it.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//get_user_setting = JS saved UI setting. else no-js-falback code.
|
//get_user_setting = JS saved UI setting. else no-js-falback code.
|
||||||
if ( 'hide' == get_user_setting('default_password_nag') || isset($_GET['default_password_nag']) && '0' == $_GET['default_password_nag'] ) {
|
if ( 'hide' == get_user_setting('default_password_nag') || isset($_GET['default_password_nag']) && '0' == $_GET['default_password_nag'] ) {
|
||||||
delete_user_setting('default_password_nag');
|
delete_user_setting('default_password_nag');
|
||||||
update_usermeta($user_ID, 'default_password_nag', false);
|
update_user_option($user_ID, 'default_password_nag', false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action('profile_update', 'default_password_nag_edit_user', 10, 2);
|
add_action('profile_update', 'default_password_nag_edit_user', 10, 2);
|
||||||
function default_password_nag_edit_user($user_ID, $old_data) {
|
function default_password_nag_edit_user($user_ID, $old_data) {
|
||||||
global $user_ID;
|
global $user_ID;
|
||||||
if ( ! get_usermeta($user_ID, 'default_password_nag') ) //Short circuit it.
|
if ( ! get_user_option('default_password_nag') ) //Short circuit it.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$new_data = get_userdata($user_ID);
|
$new_data = get_userdata($user_ID);
|
||||||
|
|
||||||
if ( $new_data->user_pass != $old_data->user_pass ) { //Remove the nag if the password has been changed.
|
if ( $new_data->user_pass != $old_data->user_pass ) { //Remove the nag if the password has been changed.
|
||||||
delete_user_setting('default_password_nag');
|
delete_user_setting('default_password_nag');
|
||||||
update_usermeta($user_ID, 'default_password_nag', false);
|
update_user_option($user_ID, 'default_password_nag', false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action('admin_notices', 'default_password_nag');
|
add_action('admin_notices', 'default_password_nag');
|
||||||
function default_password_nag() {
|
function default_password_nag() {
|
||||||
global $user_ID;
|
if ( ! get_user_option('default_password_nag') ) //Short circuit it.
|
||||||
if ( ! get_usermeta($user_ID, 'default_password_nag') )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
echo '<div class="error default-password-nag"><p>';
|
echo '<div class="error default-password-nag"><p>';
|
||||||
|
@ -242,7 +242,7 @@ function reset_password($key, $login) {
|
|||||||
do_action('password_reset', $user, $new_pass);
|
do_action('password_reset', $user, $new_pass);
|
||||||
|
|
||||||
wp_set_password($new_pass, $user->ID);
|
wp_set_password($new_pass, $user->ID);
|
||||||
update_usermeta($user->ID, 'default_password_nag', true); //Set up the Password change nag.
|
update_user_option($user_ID, 'default_password_nag', true, true); //Set up the Password change nag.
|
||||||
$message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
|
$message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
|
||||||
$message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
|
$message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
|
||||||
$message .= site_url('wp-login.php', 'login') . "\r\n";
|
$message .= site_url('wp-login.php', 'login') . "\r\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user