Hot answers tagged

3

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 5th param. And one of these args is: force_default (bool) (optional) Whether to always show the default image, never the Gravatar. Default: false. And ...


1

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 instanceof WP_User) ) { echo get_avatar( $current_user->ID, 32 ); } }


1

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. But, I also looked at the Gravatar implementation guide, https://en.gravatar.com/site/implement/images/, which notes that you can set the default image to return ...


1

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(), 'user_name', true ); $user_names = array_map('trim', explode(',', $names)); if(!empty($user_names)) { foreach ($user_names as $key => $...


1

The easiest way to do that would be to inline some CSS in your php template. then you could replace that hardcoded image URL with the users avatar like background-image: url("' . echo $avatarURL . "); You will definitely need to fix your snippet to get the avatar as well though. currently you're returning the user ID and then trying to grab the avatar. ...


1

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 they have no Gravatar setup). I use ACF (Advanced Custom Fields) to let authors upload an image because it easily adds the image upload function to every user'...


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