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
1 Answer
Reset to default 1I 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
评论列表(0条)