It is a actually hectic day for me. Okay, I want to decide on all customers with some position, with and with some meta_data: subscriber, user_country, and user_sector for instance.
At first, I’ve a number of parameters: $position, $sector, $nation Now I must filter customers by these parameters. At first, the duty was to filter customers by roles solely. I did it this fashion:
$position = get_option('choosed_users_role'); //I get this from the database
$subscribers = get_users( $position );
$emails = array ();
foreach ( $subscribers as $subscriber ){
$emails[] = $subscriber->user_email;
}
This fashion I get all mail of the customers with the particular position. When it turned essential so as to add two extra parameters I assumed that on this means I can add different parameters for filtering.
$subscribers = get_users( $position) && get_users( $sector) && get_users( user_country);
Nevertheless it’s not proper I see now. What is the appropriate means to do that? Please assist to determine with it.
PS:
By recommendation Rup I attempted utilizing WP_User_Query:
$params = array(
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'user-country',
'worth' => '17',
'kind' => 'numeric',
),
array(
'key' => 'user-sector',
'worth' => '602',
'kind' => 'numeric',
)
)
);
However not the end result. I believe the WP_User_Query doesn’t work as a result of I attempt to get a customized ACF meta subject.