I have a problem with listing my users, who have a birthday today (for this instance today is March 3rd).
I've created a custom field 'birth_date' using tutorial here with some minor tweaks.
My WP_User_Query doesn't show any users. Here's my code:
$args = array(
'meta_key' => 'birth_date',
'meta_value' => array( 'day' => '03', 'month' => '03')
);
// The Query
$user_query = new WP_User_Query( $args );
// User Loop
if ( ! empty( $user_query->results ) ) {
foreach ( $user_query->results as $user ) {
echo '<p>' . $user->display_name . '</p>';
}
} else {
echo 'No users found.';
}
Here is var_dump of 'birth_date':
array(1) { [0]=>
array(3) {
["day"]=> string(2) "03"
["month"]=> string(2) "03"
["year"]=> string(4) "1992"
} }
I suspect there is a problem with the way I express 'meta_value' in $args, however my knowledge in PHP is very limited.