Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using this plugin

http://wordpress.org/plugins/user-photo/

How can I get the Profile Photo that I upload through this plugin to show in the All Users list beside the Users Name and in the admin bar? I see the below codein admin-bar.php but so confused

/**
 * Add the "My Account" item.
 *
 * @since 3.3.0
 */
function wp_admin_bar_my_account_item( $wp_admin_bar ) {
$user_id      = get_current_user_id();
$current_user = wp_get_current_user();
$profile_url  = get_edit_profile_url( $user_id );

if ( ! $user_id )
    return;

$user_info  = get_avatar( $user_id, 64 );
$user_info .= "<span class='display-name'>{$current_user->display_name}</span>";

if ( $current_user->display_name !== $current_user->user_email )
    $user_info .= "<span class='username'>&nbsp;-&nbsp;{$current_user->user_email}</span>";


$wp_admin_bar->add_menu( array(
    'id'        => 'my-account',
    'parent'    => 'top-secondary',
    'title'     => $user_info,
    'meta'      => array(
        'class'     => 'ProCorner',
        'title'     => __('My FRS ID'),
    ),
) );

}

share|improve this question
    
Code below covers the All User List only, the admin bar is a separate issue. –  userabuser Jun 14 '13 at 4:45
    
@userabuser Hey, any suggestions if the custom user column called "photo" is displaying the word "array" for every profile field? –  Jusherb Jun 14 '13 at 20:25
    
@userabuser What does the column key do? What is "user_photo" used to for? –  Jusherb Jun 14 '13 at 20:45
    
The column key is the array key you set to specify the array item that will show itself in the users list. $new_order[key] = value - the value is what you physically see as the columns title. The array key is for the purpose of assigning a value (Photo) but also to order the item in the array, in this case we are inserting this item at the start of the array (left most) by searching for the username key and inserting out custom key before it. In the second function shown in my answer, we then use the key we specified to intercept the array pointer at this column and inject our custom data. –  userabuser Jun 15 '13 at 3:48
add comment

1 Answer

You need to add a custom column to the user list screen like so,

//Add a custom user column called Photo with a column key of user_photo 
//and re-arrange the columns array so our new column appears first.
function add_user_columns( $defaults ) {

    $new_order = array();

    foreach($defaults as $key => $title) {

        if ($key=='username') {
            $new_order['user_photo'] = __('Photo', 'user-column');
        }

        $new_order[$key] = $title;

    }

    return $new_order;

}

add_filter('manage_users_columns', 'add_user_columns', 15, 1);

//Add data to our user column, specifically in your case get the photo from user meta
function add_custom_user_columns($value, $column_name, $id) {

      if( $column_name == 'user_photo' ) {
          //replace $meta_key with the relevant key that holds the photo
          return get_user_meta($id, $meta_key, true); 
      }

}

add_action('manage_users_custom_column', 'add_custom_user_columns', 15, 3);
share|improve this answer
    
It Started a new list with photo on top and the word array in it straight down the list. –  Jusherb Jun 14 '13 at 6:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.