【问题标题】: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()

    【讨论】:

      猜你喜欢
      • 2013-11-23
      • 2012-02-18
      • 1970-01-01
      • 2014-10-18
      • 2012-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-17
      相关资源
      最近更新 更多