9 votes

Get only the author profile picture image url inside a loop

Putting the following inside loop should fulfill your needs: <?php $get_author_id = get_the_author_meta('ID'); $get_author_gravatar = get_avatar_url($get_author_id, array('size' => 450)); if(...
Abdul Awal Uzzal's user avatar
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,734
6 votes

Add aditional class to get_avatar when showing image

I had this problem, too. Here's the solution for version 4.7.3 if anyone comes across this. get_avatar( $id_or_email = get_the_author_meta( 'user_email' ), $size = '60', $default, $alt, $args = array(...
gavsiu's user avatar
  • 213
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
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
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
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
3 votes

How to change user`s avatar?

You need a little more code for the avatar_defaults hook to work than the Ray Mitchell answer, I found this code on the wordpress codex pages and it worked fine thanks to the normalized user id passed ...
jilt's user avatar
  • 51
3 votes

Buddypress update user avatar image via REST

I finally found a SOLUTION and i want to post it because can be useful for someone! public function update_user_avatar() { global $json_api; if (!$json_api->query->user_id) { $...
Biagio Pietro Capece's user avatar
2 votes

Change avatar on themed profile page

I also use Simple Local Avatars with Theme my login . I have had the same problem. My solution is very simple .Check form in profile-form.php template directory. And add enctype attribute to form (...
user114542'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,200
2 votes
Accepted

How to set custom avatar for users?

We can use the get_avatar_url filter to modify the avatar's url. If all the relevant get_avatar() calls, have user id as an input argument, then it's easy to get the corresponding user's meta value, ...
birgire's user avatar
  • 67.1k
2 votes
Accepted

How to restore $args for get_avatar custom "class"?

If you look at the documentation for teh get_avatar() filter, you'll see that callbacks can accept 6 arguments: apply_filters( 'get_avatar', string $avatar, mixed $id_or_email, int $size, string $...
Jacob Peattie'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.1k
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,734
1 vote

Add aditional class to get_avatar when showing image

Try this one.. <?php echo get_avatar( get_the_author_meta('ID'), $args['image_size'], '', 'alt', array('class' => 'avatar_class') ); ?> Example: <?php echo get_avatar( ...
Pial Arifur Rahman's user avatar
1 vote

Displaying avatar of a user

Hey pass the current user email id in get_avatar() function if user is logged in like this. <?php if ( is_user_logged_in() ) { $current_user = wp_get_current_user(); if ( ($current_user ...
Ashvin Monpara's user avatar
1 vote
Accepted

How would I be able to use a font awesome icon as a user's avatar?

Yes, it would. You can use get_avatar filter and display whatever you want as avatar. Here's an example: function my_custom_avatar( $avatar, $id_or_email, $size, $default, $alt ) { $user = ...
Krzysiek Dróżdż's user avatar
1 vote
Accepted

Return WP avatar inside a function

Replace the below line your code return get_avatar( get_the_author_meta( 'ID' ), 32 ); to return get_avatar_url( get_the_author_meta( 'ID' ) ); Hope this helps.
Krishna Joshi's user avatar
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
Accepted

Moving the WordPress dashboard avatar over the admin menu

You could make a custom menu item using a plugin called Admin Menu Editor And you could hide the avatar using CSS, to do this you could use a plugin to insert CSS in the admin dashboard or just ...
Carlos Rodríguez's user avatar
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

The "Profile Picture" section just disappeared from my User Profile

The profile picture is shown in your profile only if you have the Show Avatar option enabled in the discussion settings. Head over to Settings > Discussions and under Avatars section, enable the ...
Johansson's user avatar
  • 15.3k
1 vote

Hexagon avatar with get_avatar()

You can use the extra_attr input argument to add extra arguments to the gravatar's image tag: <?php echo get_avatar( ThemexUser::$data['user']['ID'], 200, ...
birgire's user avatar
  • 67.1k
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,921
1 vote
Accepted

How to make current user's avatar + display name link to their profile?

Use get_the_author_link() or get_the_author_meta('user_url', $user_id). Your code would become something like: $author_link = get_the_author_link(); $header .= '<div><a href="'. $author_link ...
Pim's user avatar
  • 1,152
1 vote

Get only the author profile picture image url inside a loop

just use the function get_avatart_uri() and pass in the user's email as the parameter it will give you the avatar image url
Vinit Patil's user avatar

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