WordPress.org

Make WordPress Core

Ticket #12441: _fill_user.diff

File _fill_user.diff, 1.3 KB (added by scribu, 8 years ago)
  • wp-includes/user.php

     
    316316 * @return mixed Will be an array if $single is false. Will be value of meta data field if $single
    317317 *  is true.
    318318 */
    319 function get_user_meta($user_id, $key, $single = false) {
     319function get_user_meta($user_id, $key = '', $single = false) {
    320320        return get_metadata('user', $user_id, $key, $single);
    321321}
    322322
     
    504504function _fill_user( &$user ) {
    505505        global $wpdb;
    506506
    507         $show = $wpdb->hide_errors();
    508         $metavalues = $wpdb->get_results($wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = %d", $user->ID));
    509         $wpdb->show_errors($show);
     507        $metavalues = get_user_meta($user->ID);
    510508
    511         if ( $metavalues ) {
    512                 foreach ( (array) $metavalues as $meta ) {
    513                         $value = maybe_unserialize($meta->meta_value);
    514                         $user->{$meta->meta_key} = $value;
    515                 }
    516         }
     509        if ( $metavalues )
     510                foreach ( $metavalues as $metakey => $metavalue )
     511                        $user->{$metakey} = maybe_unserialize($metavalue[0]);
    517512
    518513        $level = $wpdb->prefix . 'user_level';
    519514        if ( isset( $user->{$level} ) )
     
    666661        wp_cache_delete($user->user_nicename, 'userslugs');
    667662}
    668663
    669 ?>
    670  No newline at end of file
     664?>