Switch to *_user_option() for default password nag to avoid extra DB queries. Fixes #11380
git-svn-id: http://svn.automattic.com/wordpress/trunk@12983 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
16a769cde9
commit
041c570da1
|
@ -64,7 +64,7 @@ function wp_install( $blog_title, $user_name, $user_email, $public, $deprecated
|
|||
$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.');
|
||||
$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 {
|
||||
$random_password = '';
|
||||
$message = __('User already exists. Password inherited.');
|
||||
|
|
|
@ -807,34 +807,33 @@ endif;
|
|||
add_action('admin_init', 'default_password_nag_handler');
|
||||
function default_password_nag_handler($errors = false) {
|
||||
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;
|
||||
|
||||
//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'] ) {
|
||||
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);
|
||||
function default_password_nag_edit_user($user_ID, $old_data) {
|
||||
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;
|
||||
|
||||
$new_data = get_userdata($user_ID);
|
||||
|
||||
if ( $new_data->user_pass != $old_data->user_pass ) { //Remove the nag if the password has been changed.
|
||||
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');
|
||||
function default_password_nag() {
|
||||
global $user_ID;
|
||||
if ( ! get_usermeta($user_ID, 'default_password_nag') )
|
||||
if ( ! get_user_option('default_password_nag') ) //Short circuit it.
|
||||
return;
|
||||
|
||||
echo '<div class="error default-password-nag"><p>';
|
||||
|
|
|
@ -242,7 +242,7 @@ function reset_password($key, $login) {
|
|||
do_action('password_reset', $user, $new_pass);
|
||||
|
||||
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(__('Password: %s'), $new_pass) . "\r\n";
|
||||
$message .= site_url('wp-login.php', 'login') . "\r\n";
|
||||
|
|
Loading…
Reference in New Issue