Title: filter &#039;get_avatar&#039;
Last modified: August 21, 2016

---

# filter 'get_avatar'

 *  [thos](https://wordpress.org/support/users/thos/)
 * (@thos)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/filter-get_avatar/)
 * Hi
 * In my site, users can upload their own avatar from their profile. It create a
   user_meta called “avatar” where the url is stored.
 * I’d like to display this avatar on my site, and if the user doesn’t have upload
   an avatar, display the gravatar.
 * I try to use a filter to do it, but it doesn’t work. Here is my code. I’ve modified
   code found in internet
 *     ```
       function be_gravatar_filter($avatar, $id_or_email, $size, $default, $alt) {
       	$custom_avatar = get_the_author_meta('avatar');
       	if ($custom_avatar)
       		$return = '<img src="http://freeletics-stats.com/'.$custom_avatar.'" width="'.$size.'" height="'.$size.'" alt="'.$alt.'" />';
       	elseif ($avatar)
       		$return = $avatar;
       	else
       		$return = '<img src="'.$default.'" width="'.$size.'" height="'.$size.'" alt="'.$alt.'" />';
   
       	return $return;
       }
       add_filter('get_avatar', 'be_gravatar_filter', 10, 5);
       ```
   
 * I don’t understand how the parametres are set. With that code, all users on comments
   has the same avatar : mine.
 * Any ideas? Thanks

The topic ‘filter 'get_avatar'’ is closed to new replies.

## Tags

 * [get_avatar](https://wordpress.org/support/topic-tag/get_avatar/)

 * 0 replies
 * 1 participant
 * Last reply from: [thos](https://wordpress.org/support/users/thos/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/filter-get_avatar/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
