get_avatar won’t show uploaded avatar, only default gravatar
And of course as soon as I post the question, I find the answer. slaps forehead <?php global $current_user; get_currentuserinfo(); echo get_avatar( $current_user->ID, 48 ); ?>
And of course as soon as I post the question, I find the answer. slaps forehead <?php global $current_user; get_currentuserinfo(); echo get_avatar( $current_user->ID, 48 ); ?>
Your page seems to be currently using gravatars for comments, which is typical WP mechanics. Users with gravatar accounts will have their gravatars show up. WordPress doesn’t natively provide “local” (specific to the site) avatars. You will need to use a third party plugin/solution if you want that.
You didn’t add any code (make sure you add your own code next time because nobody bothers to help you if we have to guess the problem) but Im pretty sure I know what’s wrong. Straight out of the WordPress codex: echo get_avatar( $user_id_or_email, $avatar_size, $default_avatar, $alt_text, $args ); You have to echo it because … Read more
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 Show Avatars checkbox and save the changes. Now you can see that your profile picture is back in your profile.
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 ); } }
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(), passing the value through the ‘get_avatar’ filter and returning early. E.g. add_filter( ‘pre_get_avatar’, ‘my_filter_pre_get_avatar’, 10, 3 ); function my_filter_pre_get_avatar( $avatar_html, $id_or_email, $args ) { if ( … Read more
This a short compilation of the multiple comments above, so that future visitors don’t have to read each and every one of them. First of all, the_author_posts_link() is a deprecated function since version 2.1, so get_author_posts_url() or the_author_posts_url() should be used instead http://codex.wordpress.org/Function_Reference/get_author_posts_url The the/get_author_posts_url() takes an argument that requires “ID of the author whose … Read more
You could use the auto generated Gravatar options in the back end which will randomly assign an “avatar” to those who do not have one. You will find this when you go to your WordPress back-end Settings > Discussion and scroll down to the bottom. Or you can have a custom avatar replacement for those … Read more
The function get_avatar‘s 3rd argument is the default image, which you can also pass a function’s return value to, so wherever you run get_avatar in your theme you can set a function that changes the default avatar as a 3rd argument. get_avatar( get_the_author_meta( ‘user_email’ ), 64, ‘http://example.com/path/to/image.jpg’ ); Or, with a function’s return value as … Read more
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. add_filter(‘get_avatar_url’, ‘wpse_avatar_or_gravatar’, 10, 3); function wpse_avatar_or_gravatar($url, $id_or_email, $args) { // was id passed via $id_or_email if ($id_or_email == intval($id_or_email)) … Read more