0

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 }
?>  

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.