I'm trying to read the birthdays of the users in my database through custom fields that have been added. Displaying the current months is easy but I am trying to capture the current month(remainder) and capture part of the next month (10-15 days) based on the current day. I don't understand how to order by the current months and days so they are in ascending order. Not sure if the issue is something in my arguments or something I should be doing in my foreach loop. I could sure use some help trying to understand where I'm going wrong or if my approach is wrong. Thank You.
$current_month = date( 'n' ); // 1-12
$current_day = date( 'j' ); // 1-31
$next_month = date('n', strtotime('next month'));
$day_span = 28 - $current_day;
$args_birthday_current = [
'role__in' => ['subscriber'],
//'order' => 'ASC',
'orderby' => ['birth_day' =>'ASC', /*'birth_month' =>'ASC'*/],
'meta_query' => array(
'relation' => 'OR',
array( 'relation' => 'AND',
'birth_month' => array(
'key' => 'birth_date_month',
'value' => $current_month,
'compare' => '=',
),
'birth_day' => array(
'key' => 'birth_date_day',
'value' => $current_day,
'compare' => '>=',
),
),
array( 'relation' => 'AND',
'next_month' => array(
'key' => 'birth_date_month',
'value' => $next_month,
'compare' => '=',
),
'day_span' => array(
'key' => 'birth_date_day',
'value' => $day_span,
'compare' => '>=',
),
),
),
];
My Loop
foreach ( $user_query->get_results() as $user ) {
$birth_date_month_number = get_user_meta($user->ID, 'birth_date_month', true);
$birth_date_day_number = get_user_meta($user->ID, 'birth_date_day', true);
$birthday = date('F jS', mktime(0, 0, 0, $birth_date_month_number, $birth_date_day_number, 0));
$user_id = "user_".$user->ID;
$badge = get_field('user_profile_photo', $user_id);
echo '<a class="profile-link" href="profile-page/user/index.php?user=' . $user->last_name . '"><div>';
echo '<div class="thumbnail-wrapper"><img class="img-fluid small-thumb" src="' . $badge['sizes']['thumbnail'] . '" alt="' . $badge['alt'] . '" /></div>';
echo '<div class="profile-wrapper">' . $user->first_name . ' ' . $user->last_name . '<br>' . $birthday . '</div>';
echo '</div></a>';
}