Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save champsupertramp/cf6e0bfbaa2691eabda172d7d67a6ff7 to your computer and use it in GitHub Desktop.
Save champsupertramp/cf6e0bfbaa2691eabda172d7d67a6ff7 to your computer and use it in GitHub Desktop.
Ultimate Member - Display Profiles with Upcoming Birthdays in the Member Directory
add_action('um_user_before_query','um_061522_show_upcoming_birthdays', 10, 2);
function um_061522_show_upcoming_birthdays( $query_args, $obj ){
$directory_id = $obj->get_directory_by_hash( sanitize_key( $_POST['directory_id'] ) );
if( 325 !== $directory_id ) return $query_args;
add_action( 'pre_user_query', function( $uqi ) {
global $wpdb;
$search_meta = $wpdb->prepare("
ID IN ( SELECT user_id FROM wp_usermeta
WHERE meta_key = %s AND meta_value NOT LIKE '%". date("/m/d") ."%' AND (
( DATE_ADD( meta_value,
INTERVAL YEAR( CURDATE() ) - YEAR( meta_value )
+ IF( DAYOFYEAR( CURDATE() ) >= DAYOFYEAR( meta_value )
,1,0)
YEAR) BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 7 DAY) )
)
)", 'birth_date');
$uqi->query_where = str_replace(
'WHERE 1=1',
"WHERE 1=1 AND (" . $search_meta ." ) ",
$uqi->query_where );
});
}
@viprogress777
Copy link

This code doesn't work, it's confusing people

@hhlavyis1948
Copy link

Agreed. It doesn't work for me. The "show today's birthdays" works but not recent or upcoming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment