I’ve a person base of a whole lot of customers, and attempting to create a customized API endpoint to get customers in a particular membership group.
The database construction is as follows (utilizing Final Member plugin):
- Person is saved in
wpma_users
desk - Person metadata in desk
wpma_usermeta
incorporates person meta namedmygroups
, containing a pricea:1:{i:0;s:3:"155";}
- The
155
worth is the ID of a time period
I already tried this, with $groupid=155
:
$args = array(
'fields' => 'all_with_meta',
'tax_query' => array(
array(
'taxonomy' => 'mygroups',
'area' => 'term_id',
'phrases' => $groupid,
),
),
);
$user_query = new WP_User_Query($args);
After I var_dump get_terms(array('embody' => $groupid))
, an precise time period is printed:
array(1){
[
0
]=>object(WP_Term)#27633(10){
[
"term_id"
]=>int(155)[
"name"
]=>string(8)"Instance Group"[
"slug"
]=>string(8)"example_group"[
"term_group"
]=>int(0)[
"term_taxonomy_id"
]=>int(155)[
"taxonomy"
]=>string(11)"um_user_tag"[
"description"
]=>string(0)""[
"parent"
]=>int(149)[
"count"
]=>int(1)[
"filter"
]=>string(3)"uncooked"
}
}
One other approach I attempted, is utilizing the meta_query
as an alternative of the tax_query:
'meta_query' => array(
array(
'key' => 'mygroups',
'worth' => $groupid,
'evaluate' => 'LIKE',
)
),
This really filters the question, however after I use $groupid=1
, it filters the place groupid
incorporates 1
, so additionally 10
, 11
, 100
and so on.
Who can level me in the fitting route to filter the person on mygroups
the fitting approach?