admin管理员组文章数量:1130349
I would like to display the avatar of a user.
.jpg I want to do custom styling, such as the circled avatar.
I have read there is code, and I am assuming this is the one I am wanting to use, I am not exactly sure where the code is supposed to go.
<?php
global $current_user;
if ( is_user_logged_in() ):
get_currentuserinfo();
echo get_avatar( $current_user->ID, 64 );
endif;
?>
I would like to display the avatar of a user.
https://i.sstatic/99nOA.jpg I want to do custom styling, such as the circled avatar.
I have read there is code, and I am assuming this is the one I am wanting to use, I am not exactly sure where the code is supposed to go.
<?php
global $current_user;
if ( is_user_logged_in() ):
get_currentuserinfo();
echo get_avatar( $current_user->ID, 64 );
endif;
?>
Share
Improve this question
edited Dec 11, 2018 at 17:19
W__
asked Dec 11, 2018 at 17:12
W__W__
91 silver badge3 bronze badges
1 Answer
Reset to default 1Hey 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 );
}
}
I would like to display the avatar of a user.
.jpg I want to do custom styling, such as the circled avatar.
I have read there is code, and I am assuming this is the one I am wanting to use, I am not exactly sure where the code is supposed to go.
<?php
global $current_user;
if ( is_user_logged_in() ):
get_currentuserinfo();
echo get_avatar( $current_user->ID, 64 );
endif;
?>
I would like to display the avatar of a user.
https://i.sstatic/99nOA.jpg I want to do custom styling, such as the circled avatar.
I have read there is code, and I am assuming this is the one I am wanting to use, I am not exactly sure where the code is supposed to go.
<?php
global $current_user;
if ( is_user_logged_in() ):
get_currentuserinfo();
echo get_avatar( $current_user->ID, 64 );
endif;
?>
Share
Improve this question
edited Dec 11, 2018 at 17:19
W__
asked Dec 11, 2018 at 17:12
W__W__
91 silver badge3 bronze badges
1 Answer
Reset to default 1Hey 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 );
}
}
本文标签: Displaying avatar of a user
版权声明:本文标题:Displaying avatar of a user 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749107362a2316797.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论