Conditional avatar

A few months ago I wrote a discussion over at this WordPress.org thread regarding this. Check it out: http://wordpress.org/support/topic/custom-avatar-4?replies=5 Here is the code you’ll need in the template you want your avatars: <?php $uploads = wp_upload_dir(); //WordPress upload path $uploads_url = ( $uploads[‘baseurl’] ); //full url of upload dir $uploads_dir = ( $uploads[‘basedir’] ); //full … Read more

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

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 $default, string $alt, array $args ) Which means that your callback function is accepting the arguments correctly, including the 6th argument, $args: function tsm_acf_profile_avatar( $avatar, $id_or_email, $size, $default, … Read more

Display avatar of user profile when logged in

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 ‘Welcome : ‘ . esc_html( $current_user->display_name ); echo get_avatar( $current_user->ID, 32 ); } }

show author avatar

The get_the_author_meta function gets the Post’s author ID, not the comment-author’s information. The get_avatar() function is perfectly capable of accepting the comment object whole and working it out from that all by itself. So just call it like so: echo get_avatar( $comment, 32 );