0

I need to programmatically pull a list of all Wordpress users that are set to a specific bbPress role. WP_User_Query looks perfect and I've been playing around with the meta query attribute but I can't dial in a key/value that returns what I need.

Any ideas?

RyanMac
  • 767
  • 1
  • 6
  • 18

2 Answers2

0

Occams razor.

I falsely assumed I would have to search on meta values. It turns out you can simply pass a bbpress role (the tag value, not the friendly name) into the 'role' value in your argument list.

$args  = array(
'role' => 'bbp_custom_role',
...

$wp_user_query = new WP_User_Query($args);
RyanMac
  • 767
  • 1
  • 6
  • 18
0

you can do it by meta key and meta value in wp user query

$args = array(
    'meta_query' => array(
        'relation' => 'OR',
        0 => array(
            'key'     => 'bb_meta_key',
            'value'   => 'bb_user_role',
            'compare' => '='
        ),

    )
 );
$user_query = new WP_User_Query( $args );
Dinesh
  • 4,066
  • 5
  • 21
  • 35