wordpress - Wordpress 用户条件标签
问题描述
我怎样才能使wordpress用户条件标签像这样
<?php if (current user has fill first_name field()){ ?>
your info is complete
<?php } else { ?>
you need to fill first_name field
<?php } ?>
请帮助我,谢谢
解决方案
您可以使用get_the_author_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';
}
推荐阅读
- excel - 在 Excel VBA 中创建循环
- r - Is there an R library for drawing polygons and than generating RGB array?
- tortoisesvn - Is there a way to set up LabVIEW Compare option with TortoiseSVN programmatically?
- python - Why is my variable not defined even if I used "global"?
- java - 弹簧靴。如何利用原型范围?
- c# - 2018 年与日期 2018-01-01 之间的差异
- python - 如何从 PDF 或 Word 中提取图像以及图像周围的文本?
- reactjs - @svgr/webpack 从 'paths/xx.svg' 导入 xx 错误
- wifi - 为什么 Scapy 在 Dot11 元素信息中添加了“c2”字节?
- r - 如何在应用函数中使用 if 语句?