[英]How to integrate the user's avatar in code from Buddypress?
I have a template that display a bubble with an image in it. 我有一个模板,其中显示带有图像的气泡。 But I would like to replace this image by the logged in user's avatar from Wordpress.
但是我想用Wordpress中已登录用户的头像替换该图像。
How can I do that ? 我怎样才能做到这一点 ?
Here is the code of my section : 这是我部分的代码:
<?php
$latte_intro_avatar = get_theme_mod('latte_intro_avatar', get_template_directory_uri().'/assets/images/avatar.jpg' );
$latte_intro_scroll = get_theme_mod('latte_intro_scroll', '#about' );
?>
<section class="intro" id="intro">
<div class="container">
<div class="cover-container row">
<div class="inner cover col-md-12">
<?php if(!empty($latte_intro_avatar)) : ?>
<div class="avatar" style="background-image:url('<?php echo esc_url($latte_intro_avatar); ?>');"></div>
<?php endif; ?>
<h1 class="cover-heading"><?php bloginfo( 'name' ); ?></h1>
<p class="lead"><?php bloginfo( 'description' ); ?></p>
<?php if(!empty($latte_intro_scroll)) : ?>
<a href="<?php echo esc_url($latte_intro_scroll); ?>" class="arrow"><i class="fa fa-arrow-circle-down"></i></a>
<?php endif; ?>
</div>
</div>
</div>
</section>
Found the solution : 找到了解决方案:
<?php
global $current_user;
if ( is_user_logged_in() ):
get_currentuserinfo();
echo get_avatar( $current_user->ID, 64 );
endif;
?>
Works like a charm. 奇迹般有效。 source : https://wordpress.stackexchange.com/questions/173626/display-avatar-of-user-profile-when-logged-in
来源: https : //wordpress.stackexchange.com/questions/173626/display-avatar-of-user-profile-when-logged-in
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.