根据用户角色隐藏字段

时间:2018-02-08 15:04:08

标签: php css wordpress

如何使用CSS为特定用户隐藏字段?
像这样:

ngIf

我使用了这段代码并且无效:

if( $role == 'subscriber' ) {    ?>
<style type="text/css">
    .user-area .user-profile-dropdown{
        display: none !important;
    }
</style>

2 个答案:

答案 0 :(得分:0)

您缺少关闭HTML输出:

function hide_fields_nonusers(){
if( $role == 'subscriber' ) {    ?>
<style type="text/css">
  .user-area .user-profile-dropdown{
     display: none !important;
 }
</style>
<?php }

答案 1 :(得分:0)

想出来:

if( current_user_can('subscriber')) {   
?>
<style type="text/css">
.user-area .user-profile-dropdown{
 display: none !important;
 }
</style>
<?php 

}