php - Get all objects that have a certain term -


i've been looking @ function reference wp_user_query, wp_get_object_terms neither of these seem need. wp_user_query lets filter user meta isn't helpful. wp_get_object_terms lets pass object id , taxonomy , return terms in taxonomy object has.

i need that's reverse of that. have taxonomy called 'tags' can attached users, , need able "get me users have tags x , y". should using accomplish this?

i facing same issue had users tags/ categories. , wanted users have category signatory. used combination of

here solution

$args = array(     'blog_id'      => $globals['blog_id'],     'role'         => '',     'role__not_in' => array('administrator', 'bbp_keymaster'),     'count_total'  => false,     'fields'       => 'all',     'who'          => '' );  $blogusers = get_users( $args ); 

in div, output way

<div class="title-tag">featured signatory</div>  <?php foreach ( $blogusers $user ) : ?>     <?php       $terms = wp_get_object_terms( $user->id, 'user_category' );      foreach ( $terms $tax ) {          if ($tax->slug === 'signatory') {              echo '<p> ' . $user->display_name . '  </p>';          }      }     ?> <?php endforeach; ?> 

this give users have tag or category of choice.

hope helps else has bunch of user meta included in users profile.


Comments