Displaying Logged-In User Name and avatar in WordPress Menu

You can use “get_avatar” function to display avatar in menu with user name. Please try code given below: add_filter( ‘wp_nav_menu_objects’, ‘my_dynamic_menu_items’, 10 ); function my_dynamic_menu_items( $menu_items ) { foreach ( $menu_items as $menu_item ) { if ( strpos($menu_item->title, ‘#profile_name#’) !== false) { $menu_item->title = str_replace(“#profile_name#”, wp_get_current_user()->user_login .’ ‘. get_avatar( wp_get_current_user()->user_email, 50), $menu_item->title); } } return … Read more

How to get larger version of author avatar

I found the function that makes up bp_post_author_avatar() and then changed the type to full. Place this funtion in functions.php and use the new function to call the post author avatar in the template. function fod_post_author_avatar() { global $post; if ( function_exists(‘bp_core_fetch_avatar’) ) { echo apply_filters( ‘bp_post_author_avatar’, bp_core_fetch_avatar( array( ‘item_id’ => $post->post_author, ‘type’ => ‘full’ … Read more

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 );

get the avatar url instead of an html img tag when using get_avatar?

It’s fairly simple to construct the Gravatar URL yourself, it’s just an MD5 hash of the user’s email address. <?php $gravatar=”http://www.gravatar.com/avatar/” . md5(strtolower($email)) . ‘&s=32’; ?> <div class=”avatar” style=”background: url(<?php echo $gravatar ?>);” ></div> The s parameter at the end there defines the size of the image in pixels. Using Gravatars – WordPress Codex

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 from the Settings > Discussion page. add_filter( ‘avatar_defaults’, ‘add_new_gravatar_image’ ); function add_new_gravatar_image($avatar_defaults) { $myavatar=”http://yoursite.com/image.png”; $avatar_defaults[$myavatar] = “Default … Read more

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. foreach ( $blogusers as $user ) { /* Here passing user email and avater size */ echo get_avatar( $user->user_email , 96 ); echo … Read more

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