This may help you:
https://codex.wordpress.org/Using_GravatarsTheme Support for WordPress 2.5+The function to add Gravatars to your theme is called: get_avatar. The function returns a complete image HTML tag of the Avatar.
The function is called as follows:
- Code: Select all
<?php
echo get_avatar( $id_or_email, $size = '96', $default = '<path_to_url>' );
?>
The parameters are:
- id_or_email (required): Author’s User ID (an integer or string), an E-mail Address (a string) or the comment object from the comment loop. Note: with most comment templates you can use $comment here, in order to display the gravatar of the commenter. In other templates within The Loop (for WordPress 2.7 and lower), you can use get_the_author_id() (deprecated in WordPress 2.8). For WordPress 2.8, please use get_the_author_meta('user_email').
- size (optional): Avatar display size (max is 512).
- default (optional): Absolute location of the default avatar to use (used when the person has no email address associated with them). If this is left blank then the gravatar you see here will be used as the default avatar.
Some things to note here:
- The default Avatar size is 96x96 if you do not set the size using the size paramater.
- The default Avatar is Gravatar
- The Avatars will show only if the user allows them in the WP Admin Panel (enabled by default).
- The Avatars will only show based on the rating the user has selected in the WordPress Administration Panels.
Code output:
The default output is when using the above function is listed below. Various classes are applied to img element to help you with element styling.
- Code: Select all
<img alt='' src='http://gravatarurl_or_default' class='avatar avatar-$size' height='$size' width='$size' />
If the gravatar reverts to the default image due to a lack of an e-mail address (i.e. a pingback or trackback), whether you have specified a default or not, the img element will also be given a CSS class of avatar-default.
See also:
https://codex.wordpress.org/Function_Re ... get_avatarNow, for the user's name, this may be what you need:
https://codex.wordpress.org/Function_Re ... rrent_userExamplesE.g.: To determine if there is a user currently logged in, do this:
- Code: Select all
<?php
wp_get_current_user();
if ( 0 == $current_user->ID ) {
} else {
}
?>
Default UsageThe call to wp_get_current_user() return WP_User object.
- Code: Select all
<?php
wp_get_current_user();
echo 'Username: ' . $current_user->user_login . '<br />';
echo 'User email: ' . $current_user->user_email . '<br />';
echo 'User first name: ' . $current_user->user_firstname . '<br />';
echo 'User last name: ' . $current_user->user_lastname . '<br />';
echo 'User display name: ' . $current_user->display_name . '<br />';
echo 'User ID: ' . $current_user->ID . '<br />';
?>
Let me know if that helps.