Query Subscribers By Custom Meta Key Called Country

Home » Snippets » Query Subscribers By Custom Meta Key Called Country
0

Created with:

WP_User_Query Generator

Visibility: 

public

Creator: WPTurbo Team

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project
				$query_args = [
	'role__in' => [
		'Subscriber',
	],
	'meta_query' => [
		[
			'key' => 'Country',
			'value' => 'United States',
			'compare' => '=',
		],
	],
];

$query = new WP_User_Query( $query_args );

if ( ! empty( $query ) && ! is_wp_error( $query ) ) {
	// The Loop
}
else {
	// no terms found
}
			

Register an account to save your snippets or go Pro to get more features.