WordPress.org

Make WordPress Core

Changeset 11162


Ignore:
Timestamp:
05/03/2009 05:06:29 PM (11 years ago)
Author:
westi
Message:

Add a nag message if the user is still using an auto-generated password. See #9710 props DD32.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/upgrade.php

    r11040 r11162  
    6161        $random_password = wp_generate_password();
    6262        $user_id = wp_create_user($user_name, $random_password, $user_email);
     63        update_usermeta($user_id, 'default_password_nag', true);
    6364    } else {
    6465        $random_password = __('User already exists.  Password inherited.');
  • trunk/wp-admin/includes/user.php

    r11109 r11162  
    792792endif;
    793793
     794add_action('admin_init', 'default_password_nag_handler');
     795function default_password_nag_handler() {
     796    if ( 'hide' == get_user_setting('default_password_nag') || isset($_GET['default_password_nag']) && '0' == $_GET['default_password_nag'] ) {     
     797        global $user_ID;
     798        delete_user_setting('default_password_nag');
     799        update_usermeta($user_ID, 'default_password_nag', false);
     800    }
     801}
     802add_action('admin_notices', 'default_password_nag');
     803function default_password_nag() {
     804    global $user_ID;
     805    if ( ! get_usermeta($user_ID, 'default_password_nag') )
     806        return;
     807
     808    echo '<div class="error default-password-nag"><p>';
     809    printf(__("Howdy, you're still using the auto-generated password for your account. We recommend that you change it to something you'll remember easier.  Would you like to do this now?<br />
     810              <a href='%s'>Yes, Take me to my profile page</a> | <a href='%s' id='default-password-nag-no'>No Thanks, Do not remind me again.</a>"), admin_url('profile.php') . '#password', '?default_password_nag=0');
     811    echo '</p></div>';
     812}
     813
    794814?>
  • trunk/wp-admin/js/common.dev.js

    r11118 r11162  
    232232            return '';
    233233        });
     234    });
     235    $('#default-password-nag-no').click( function() {
     236        setUserSetting('default_password_nag', 'hide');
     237        $('div.default-password-nag').hide();
     238        return false;
    234239    });
    235240});
  • trunk/wp-admin/user-edit.php

    r11110 r11162  
    354354if ( $show_password_fields ) :
    355355?>
    356 <tr>
     356<tr id="password">
    357357    <th><label for="pass1"><?php _e('New Password'); ?></label></th>
    358358    <td><input type="password" name="pass1" id="pass1" size="16" value="" autocomplete="off" /> <?php _e("If you would like to change the password type a new one. Otherwise leave this blank."); ?><br />
  • trunk/wp-login.php

    r11148 r11162  
    180180    $new_pass = wp_generate_password();
    181181    wp_set_password($new_pass, $user->ID);
     182    update_usermeta($user->ID, 'default_password_nag', true); //Set up the Password change nag.
    182183    $message  = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
    183184    $message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
Note: See TracChangeset for help on using the changeset viewer.