WordPress.org

Forums

[Plugin: User Photo] Can't see photos properly in users.php (3 posts)

  1. donquixote
    Member
    Posted 6 years ago #

    Hi,

    I can see user photos everywhere where I want - posts and comments. However, I'd like to also see them in the users.php page under the administrative settings.
    From what I've read - I don't have an authors page in my theme (based on Kubric). The only place where I managed to change things was in my:
    wp-admin\includes\template.php
    where I had:
    $avatar = get_avatar( $user_object->ID, 32 );
    and I changed that to:
    $avatar = userphoto_thumbnail($user_object);

    That did show me the photos - but they don't show up in the table properly - only on top of it. I can't figure it out.

    Here's a snippet of my template.php (in the admin it shows under users.php):

    $role_name = isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role] ) : __('None');
    	$r = "<tr id='user-$user_object->ID'$style>";
    	$columns = get_column_headers('users');
    	$hidden = get_hidden_columns('users');
    	//$avatar = get_avatar( $user_object->ID, 32 );
    	$avatar = userphoto_thumbnail($user_object);
    	foreach ( $columns as $column_name => $column_display_name ) {
    		$class = "class=\"$column_name column-$column_name\"";
    
    		$style = '';
    		if ( in_array($column_name, $hidden) )
    			$style = ' style="display:none;"';
    
    		$attributes = "$class$style";
    
    		switch ($column_name) {
    			case 'cb':
    				$r .= "<th scope='row' class='check-column'>$checkbox</th>";
    				break;
    			case 'username':
    				$r .= "<td $attributes>$avatar $edit</td>";
    				break;
    			case 'name':
    				$r .= "<td $attributes>$user_object->first_name $user_object->last_name</td>";
    				break;
    			case 'email':
    				$r .= "<td $attributes><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td>";
    				break;
    			case 'role':
    				$r .= "<td $attributes>$role_name</td>";
    				break;
    			case 'posts':
    				$attributes = 'class="posts column-posts num"' . $style;
    				$r .= "<td $attributes>";
    				if ( $numposts > 0 ) {
    					$r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
    					$r .= $numposts;
    					$r .= '</a>';
    				} else {
    					$r .= 0;
    				}
    				$r .= "</td>";
    				break;
    			default:
    				$r .= "<td $attributes>";
    				$r .= apply_filters('manage_users_custom_column', '', $column_name, $user_object->ID);
    				$r .= "</td>";
    		}
    	}
    	$r .= '</tr>';
    
    	return $r;
    }

    Thanks.

  2. 9steps
    Member
    Posted 5 years ago #

    What I did was this to see thumbnails on /wp-admin/users.php under the administrative settings.

    change user-photo.php(line 79):

    if(get_option("userphoto_override_avatar") && !is_admin())

    to

    if(get_option("userphoto_override_avatar"))

    and then add a line for adding an action on admin_head(line 85):

    add_action("init", "userphoto__init");
    add_action("admin_head", "userphoto__init", 1); // add this line

    Of course, you need to set "Override Avatar with User Photo" option "on" with User Photo plugin.

  3. banesto
    Member
    Posted 5 years ago #

    BIG Thanks to 9steps!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags