Php 在Wordpress中为注册成员显示不同的内容
好的,我现在向所有访问我的WP站点的用户展示以下内容:Php 在Wordpress中为注册成员显示不同的内容,php,wordpress,templates,themes,Php,Wordpress,Templates,Themes,好的,我现在向所有访问我的WP站点的用户展示以下内容: <div class="gravatar"> <?php $user_id = get_current_user_id(); // Get the user ID $size_avatar = 50; // Set the avatar size $default_avatar = 'http://techyoucation.com/wp-content/themes/blank/images/avatar50.png';
<div class="gravatar">
<?php
$user_id = get_current_user_id(); // Get the user ID
$size_avatar = 50; // Set the avatar size
$default_avatar = 'http://techyoucation.com/wp-content/themes/blank/images/avatar50.png'; // Set your default image url
echo get_avatar( $user_id, $size_avatar, $default_avatar ); // This prints the <img> tag with correct avatar image url
?>
</div>
现在,我希望这只显示给登录到我的网站的用户,并为没有登录的用户显示不同的内容,例如
<div class="Register">
<p>Register</p>
</div>
登记册
我该怎么做
提前谢谢
Aled它有一个非常简单的功能:
<?php if (is_user_logged_in()): ?>
You're logged in.
<?php else: ?>
<div class="Register">
<p>Register</p>
</div>
<?php endif; ?>
你已经登录了。
登记册