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 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(), 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

How to link avatar and nickname to profile

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

Changing comments avatar

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

Random Default Avatar Function

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

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. 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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)