user meta - get_usersWP_User_Query returns empty when logged out

I have a fairly basic user query pulling staff members on a website I'm working on. When you are logged in to WordP

I have a fairly basic user query pulling staff members on a website I'm working on. When you are logged in to WordPress they are showing on the front-end. But when logged out they are not displaying. I did a var_dump and it is returning empty when logged out. I cannot find any logical reason for this. I tried without querying a role and it does the same thing.

<?php
$args = array(
    'role__in' => array('Staff')
);

// The Query
$user_query = get_users( $args );
var_dump($user_query);

// User Loop
    foreach ( $user_query as $user ) { ?>

        <?php $job_title = get_field('job_title', 'user_'. $user->ID ); ?>

        <div class="each-staff">

            <a class="staff-image" href="<?php echo get_author_posts_url( $user->id ); ?>"><img src="<?php echo esc_url( get_avatar_url( $user->ID ) ); ?>" /></a>
            <div class="staff-info">
                <h4 class="staff-name"><a href="<?php echo get_author_posts_url( $user->id ); ?>"><?php echo $user->display_name; ?></a></h4>
                <h5><?php echo $job_title; ?></h5>
            </div>

        </div>

    <?php }
?>  

I have a fairly basic user query pulling staff members on a website I'm working on. When you are logged in to WordPress they are showing on the front-end. But when logged out they are not displaying. I did a var_dump and it is returning empty when logged out. I cannot find any logical reason for this. I tried without querying a role and it does the same thing.

<?php
$args = array(
    'role__in' => array('Staff')
);

// The Query
$user_query = get_users( $args );
var_dump($user_query);

// User Loop
    foreach ( $user_query as $user ) { ?>

        <?php $job_title = get_field('job_title', 'user_'. $user->ID ); ?>

        <div class="each-staff">

            <a class="staff-image" href="<?php echo get_author_posts_url( $user->id ); ?>"><img src="<?php echo esc_url( get_avatar_url( $user->ID ) ); ?>" /></a>
            <div class="staff-info">
                <h4 class="staff-name"><a href="<?php echo get_author_posts_url( $user->id ); ?>"><?php echo $user->display_name; ?></a></h4>
                <h5><?php echo $job_title; ?></h5>
            </div>

        </div>

    <?php }
?>  
Share Improve this question asked Dec 19, 2019 at 11:02 Benjamin CuslidgeBenjamin Cuslidge 211 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 1

I figured out the issue is with the plugin Advanced Access Manager we used to create the custom role for Staff. There is a setting by default:

User Level Filter Extend default WordPress core users and roles handling, and make sure that users with lower user level cannot see or manager users and roles with higher level.

This was causing them to not show on the front-end. Hope this helps if anyone comes across the same problem.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742367022a4430516.html

相关推荐

  • user meta - get_usersWP_User_Query returns empty when logged out

    I have a fairly basic user query pulling staff members on a website I'm working on. When you are logged in to WordP

    3小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信