Title: insert avatar widget
Last modified: August 21, 2016

---

# insert avatar widget

 *  Resolved [Guillermo](https://wordpress.org/support/users/guillermo-kafelnikov/)
 * (@guillermo-kafelnikov)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/insert-avatar-widget/)
 * Hi Gabriel !
 * You can insert “an avatar” in “My Balance” **widget** and “Leaderboard” ?
 * if so … that codes should be inserted into the widget…?
 * I apologize if someone has asked this before…
 * Thank you very much…
 * Bye.
 * [https://wordpress.org/plugins/mycred/](https://wordpress.org/plugins/mycred/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [myCred](https://wordpress.org/support/users/designbymerovingi/)
 * (@designbymerovingi)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/insert-avatar-widget/#post-4705746)
 * Hey!
 * You can use the following code to add avatars to the leaderbaord. Each results
   row is passed though the [mycred_ranking_row](http://codex.mycred.me/filters/mycred_ranking_row/)
   filter which allows you to add / adjust things that can not be done via the template.
 *     ```
       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'], 32 ), $layout );
       }
       ```
   
 * This code goes in your themes functions.php file and introduces a new template
   tag called %avatar% which will be replaced by the users avatar.
 * But that code only works for the leaderboard so to add support for balances, 
   we would be better off registering this new template tag as a [user related tag](http://codex.mycred.me/category/template-tags/temp-user/)
   which means that everywhere where User related template tags can be used, this
   new tag will also be available. To do this, we will need to use the [mycred_parse_tags_user](http://codex.mycred.me/filters/mycred_parse_tags_user/)
   filter.
 * Example:
 *     ```
       add_filter( 'mycred_parse_tags_user', 'custom_general_template_tag', 10, 3 );
       function custom_general_template_tag( $content, $user, $data ) {
       	// Bail if user no longer exists
       	if ( ! isset( $user->ID ) ) return $content;
   
       	return str_replace( '%avatar%', get_avatar( $user->ID, 32 ), $content );
       }
       ```
   
 * Let me know if you require further assistance.
 *  Thread Starter [Guillermo](https://wordpress.org/support/users/guillermo-kafelnikov/)
 * (@guillermo-kafelnikov)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/insert-avatar-widget/#post-4705867)
 * Thank you very much !!!
 *  [fanalejr](https://wordpress.org/support/users/fanalejr/)
 * (@fanalejr)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/insert-avatar-widget/#post-4705939)
 * Hi,
    I love this plugin – this script however doesn’t seem to work for me after
   updating to 1.4 – using this on the buddyboss theme and just want to add the 
   users avatar in the leaderboard widget. It was working without a problem prior
   to updating. Now it just breaks the widget/site – Anyone else experience this?
 *  Plugin Author [myCred](https://wordpress.org/support/users/designbymerovingi/)
 * (@designbymerovingi)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/insert-avatar-widget/#post-4705940)
 * Hi fanalejr
 * Can you be a bit more specific as to how it “breaks” the widget? Have you had
   a look what CSS styles are applied to the avatar? Does it not render the template
   tag or the image is not inserted correctly?
 *  [fanalejr](https://wordpress.org/support/users/fanalejr/)
 * (@fanalejr)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/insert-avatar-widget/#post-4705941)
 * Gabriel, thanks for the response – it actually doesn’t render anything. It renders
   the title of the leaderboard widget and then stops the output all together. It
   seems to be an error with the filter –
 *     ```
       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'], 32 ), $layout );
       }
       ```
   
 * When I remove that from the functions file it renders fine.
 *  Plugin Author [myCred](https://wordpress.org/support/users/designbymerovingi/)
 * (@designbymerovingi)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/insert-avatar-widget/#post-4705942)
 * Enable WP_DEBUG and see what errors you get.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘insert avatar widget’ is closed to new replies.

 * ![](https://ps.w.org/mycred/assets/icon-128x128.gif?rev=3512531)
 * [Points Management System For Gamification, Ranks, Badges, and Loyalty Rewards Program - myCred](https://wordpress.org/plugins/mycred/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mycred/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mycred/)
 * [Active Topics](https://wordpress.org/support/plugin/mycred/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mycred/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mycred/reviews/)

 * 6 replies
 * 3 participants
 * Last reply from: [myCred](https://wordpress.org/support/users/designbymerovingi/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/insert-avatar-widget/#post-4705942)
 * Status: resolved