weedshop Posted January 5, 2020 Share Posted January 5, 2020 Hello all! I use wordpress for blogging and on this site i am trying to display users gravatars on the site. If users have not set a gravatar, then i would like it to show the "default" image it shows now. I am also looking to display the users name, nickname and a edit my profile link for the logged in users. Here is the code i have now but it will always show my gravatar: <h2><?php _e('Your Gravatar'); ?></h2> <?php global $userdata; get_currentuserinfo(); echo($userdata->first_name); echo " "; echo($userdata->last_name); ?> <?php global $user_email; get_currentuserinfo(); echo "<img src='"; echo gravatar($user_email); echo "' alt='' class='gravatar' width='60' height='60' ALIGN=LEFT />"; ?> Nickname: <?php global $userdata; get_currentuserinfo(); echo($userdata->user_login); ?> <?php global $user_email; Ooppss, here is a link to my site: https://www.weedshopinc.com and on the left side of the page you will see "your gravatar". Thanks for any help Quote Link to comment https://forums.phpfreaks.com/topic/309800-php-gravatar-code/ Share on other sites More sharing options...
maxxd Posted January 6, 2020 Share Posted January 6, 2020 (edited) There's no context around the code you've posted, but there appear to be a couple issues. First and foremost, you're using get_currentuserinfo() , which is deprecated in favor of wp_get_current_user(). Even beyond that, you're requesting the data of the currently logged in user, which is you. So actually your code is doing exactly what you've asked it to do. Another issue is that you're calling get_currentuserinfo() multiple times - if all this code is in the same template you don't need to do that. Give some context to what you're trying to do with this code. If you're in the WordPress loop, use the information about the current post. Edited January 6, 2020 by maxxd typo 1 Quote Link to comment https://forums.phpfreaks.com/topic/309800-php-gravatar-code/#findComment-1573140 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.