【问题标题】:Wordpress user conditional tagsWordpress 用户条件标签
【发布时间】:2020-08-01 15:45:13
【问题描述】:
我怎样才能使 wordpress 用户条件标签像这样
<?php if (current user has fill first_name field()){ ?>
your info is complete
<?php } else { ?>
you need to fill first_name field
<?php } ?>
请帮帮我,谢谢
【问题讨论】:
标签:
wordpress
if-statement
tags
conditional-statements
【解决方案1】:
您可以使用get_the_author_meta() 函数获取用户meta 和get_current_user_id() 获取当前用户ID。
<?php
if ( get_the_author_meta( 'user_firstname', get_current_user_id() ) ) {
echo 'your info is complete';
} else {
echo 'you need to fill first_name field';
}
参考:get_the_author_meta()get_current_user_id()