Skip to main content
7 votes

Replace Gravatar with uploaded images?

Presuming that the user has their avatar saved, as the ID of an attachment, store in user meta, as the field field_with_custom_avatar_id, you could do this to show that attachment if the value is ...
JPollock's user avatar
  • 1,248
7 votes

Custom user avatar in the Wordpress users listing

As an alternative to my other answer, you can also use the get_avatar filter. Props to Sumit to alerting me to this one. The benefit of using the get_avatar filter is your custom avatar should be ...
Tim Malone's user avatar
  • 4,754
5 votes
Accepted

How to check if gravatar of user is the default's one?

I had a look at the avatar related functions/filters WP provides and I don't think there is a direct way to tell, if the avatar is a real one or the default image as you only have url to work with. ...
Antti Koskinen's user avatar
4 votes

Listing all users by their avatars in wordpress

You have to retrieve all users with this get_users() and loop through them. Then you have to get the avatar URL using a current user id with this get_avatar_url(). $users = get_users( array( 'fields' ...
Ankur's user avatar
  • 39
4 votes
Accepted

Listing all users by their avatars in wordpress

You can jump start by using following example. Here I'll be listing users and loop through them to display avatar and display name. <?php $blogusers = get_users(); // Array of WP_User objects. ...
Sabbir Hasan's user avatar
  • 1,359
3 votes
Accepted

How to replace any occurence of Gravatars with a local placeholder image?

OK, so there are some occurrences of get_avatar() in your site. If you'll take a look at docs for this function, you'll see, that: you pass URL for default avatar image as 3rd param, you pass args as ...
Krzysiek Dróżdż's user avatar
2 votes
Accepted

Use Gravatar as fallback image if no local image is not found

You can use the get_avatar_url filter (see the arguments passed here in the source code) to change the avatar url and then simply use get_avatar() with the user email in the theme as you're used to. ...
kero's user avatar
  • 6,220
2 votes
Accepted

How to prevent a specific users's profile photo (gravatar) from showing on the frontend to other users?

Use this hook function to replace user's avatar (which is passed in as HTML <img ...> tag) if user's ID or email matches your condition. You can use any other default image, or get individual ...
Vitauts Stočka's user avatar
2 votes

Custom user avatar in the Wordpress users listing

We could also use one of the following filters, available since WordPress 4.2: pre_get_avatar_data get_avatar_url get_avatar_data Regarding how to get the user ID from the $id_or_email we can see ...
birgire's user avatar
  • 67.4k
1 vote

How to load locally saved author photos based on author ID

One option is to use the pre_get_avatar filter to return custom avatar HTML, which will short-circuit get_avatar() preventing it from reaching out to Gravatar for the image. For example like this, ...
Antti Koskinen's user avatar
1 vote
Accepted

How to change avatar of the comment author using comment ID?

You can use pre_get_avatar filter to manipulate comment avatar html and stop WP from getting a default avatar for the comment. Passing a non-null value will effectively short-circuit get_avatar(), ...
Antti Koskinen's user avatar
1 vote
Accepted

Custom Field Repeating When Using foreach

if you want to use multiple users, if you will add usernames comma separated in custom field. try below code. function user_avatar() { $user = ""; $names = get_post_meta( get_the_ID(), '...
Chetan Vaghela's user avatar
1 vote

How to replace any occurence of Gravatars with a local placeholder image?

Krzysiek has a good solution, but I do this a bit differently...because I also want to allow users to upload a locally stored image and then fall back to Gravatar if they don't (or a default image if ...
Trisha's user avatar
  • 418
1 vote

Custom user avatar in the Wordpress users listing

EDIT: My original solution is below, but Sumit alerted me in the comments to the existence of the get_avatar filter. I've posted an additional answer that shows how to implement that option as well. ...
Tim Malone's user avatar
  • 4,754
1 vote

Changing default Buddypress avatar affects all site avatars (because gravatar)

Ok so I think I found a solution and wanted to post in case this is an issue for anyone else. I decided to forgo trying to create a custom default avatar through buddypress specifically, which means ...
Haazna's user avatar
  • 33
1 vote

Gravatar image url is wrong?

As the filename suggests, it's a default for when someone does not have a gravatar assigned. It is set up in your child theme and looks to be improperly set. You should search through the child theme ...
WebElaine's user avatar
  • 9,430
1 vote

How to output nothing instead of default avatar?

Gravatar is a remote service. Most ways to do this involve ramping up communication with that remote service with considerable performance hit due to network requests. You'll have to bend backwards ...
Rarst's user avatar
  • 99.7k
1 vote

How to output nothing instead of default avatar?

You can use a function to check if the user has Gravatar set: function wps_281473_has_gravatar($email) { $hash = md5(strtolower(trim($email))); $url = 'http://www.gravatar.com/avatar/'.$hash....
Milan Petrovic's user avatar
1 vote

How to output nothing instead of default avatar?

You can use the get_avatar filter to change the output or avatar_defaults to add new image that can be placed on your server. Here is an example code for adding new avatar that you can set as default ...
Boris Kuzmanov's user avatar
1 vote
Accepted

How to add custom class to get_avatar()

The get_avatar() function has many arguments, the last one is the interesting one, because you can pass additional classes, also described in the codex. So instead of get_avatar( $comment, $args['...
kero's user avatar
  • 6,220
1 vote

Avatar picture does not display when using get_avatar

The get_avatar function is a pluggable function with it's first parameter being either the user's ID or email. You're using get_avatar with get_the_author_meta('ID') which should give you the ID of ...
Tunji's user avatar
  • 2,941
1 vote
Accepted

Working with Gravatars within a localhost development area

You cannot make gravatars work offline (they completely rely on remote service), but you can get rid of erorrs and slowdown when offline by overriding them. You can use get_avatar filter for it. ...
Rarst's user avatar
  • 99.7k
1 vote

get the avatar url instead of an html img tag when using get_avatar?

As of WordPress version 4.2.0, we can use get_avatar_url(). The function can be found in wp-includes/link-template.php: function get_avatar_url( $id_or_email, $args = null ) { $args = ...
Christine Cooper's user avatar
  • 8,798
1 vote

Removing Gravatar.com support for WordPress and Simple Local Avatars

Extension to the original question: In case you try to omit/replace the "You can change your profile picture on Gravatar" note in the Wordpress profile page, add this to the functions.php of ...
Matthias Luh's user avatar
1 vote

Alternative default avatar generator?

Drop this code in your function.php add_filter( 'avatar_defaults', 'wpb_new_gravatar' ); function wpb_new_gravatar ($avatar_defaults) { $myavatar = 'http://example.com/wp-content/uploads/2017/05/...
Mohammad Kashif's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible