• HI
    I copied your code to view avatar in list widget but the avatar Facebook not appears , normal avatar appears .
    code:
    add_filter( ‘mycred_ranking_row’, ‘my_custom_ranking_rows’, 10, 4 );
    function my_custom_ranking_rows( $layout, $template, $row, $position )
    {
    return str_replace( ‘%avatar%’, get_avatar( $row[‘user_id’], 64 ), $layout );
    }
    _
    I have a plugin install call http://wordpress.org/plugins/wp-fb-autoconnect/
    and i view in admin panel user the avatar Facebook.

    How to change this avatar for a facebook image?

    http://wordpress.org/plugins/mycred/

Viewing 1 replies (of 1 total)
  • Plugin Support muddasirhayat

    (@muddasirhayat)

    Hi @allienimmons15,

    Yes, you can display user avatars in the myCred Leaderboard by using the following leaderboard template:

    <table> 
    <thead>
    <tr> <th>Position</th>
    <th>Name</th>
    <th>Points</th>
    <th>Avatar</th>
    </tr>
    </thead>
    <tbody>
    <table>
    <thead>
    <tr> <th>Position</th>
    <th>Name</th>
    <th>Points</th>
    <th>Avatar</th>
    </tr>
    </thead>
    <tbody>

    [mycred_leaderboard wrap=""]

    <tr>
    <td>%position%</td>
    <td>%display_name%</td>
    <td>%cred_f%</td>
    <td>%avatar%</td>
    </tr>

    [/mycred_leaderboard]
    </tbody>
    </table>

    Then, add the following code to your active theme’s functions.php file:

    add_filter( 'mycred_ranking_row', 'mycredpro_add_avatars_to_leaderboard', 10, 4 );
    
    function mycredpro_add_avatars_to_leaderboard( $layout, $template, $user, $position ) {
    
        if ( isset( $user->ID ) ) {
            $user_id = $user->ID;
        } elseif ( isset( $user['ID'] ) ) {
            $user_id = $user['ID'];
        } else {
            return $layout;
        }
    
        $avatar = get_avatar( $user_id, 32 );
    
        return str_replace( '%avatar%', $avatar, $layout );
    }

    Please note that this code uses WordPress’s get_avatar() function. If your Facebook avatar plugin does not override get_avatar(), the default WordPress avatar will be displayed instead of the Facebook avatar.

    Thank you

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.