Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save champsupertramp/126176cfdb7ae08913c5154da9087e45 to your computer and use it in GitHub Desktop.
Save champsupertramp/126176cfdb7ae08913c5154da9087e45 to your computer and use it in GitHub Desktop.
Ultimate Member - Upcoming Birthday future age as tag line in the Member Directory
add_filter("um_ajax_get_members_data","um_061522_future_age_birthdays", 10, 3 );
function um_061522_future_age_birthdays( $data_array, $user_id, $directory_data ){
$directory_id = $directory_data['form_id'];
if( 325 !== $directory_id ) return $data_array;
um_fetch_user( $user_id );
$hours_in_day = 24;
$minutes_in_hour= 60;
$seconds_in_mins= 60;
$birth_date = new DateTime( um_user("birth_date") );
$current_date = new DateTime();
$diff = $birth_date->diff($current_date);
$years = $diff->y + 1;
$months = ($diff->y * 12) + $diff->m + 1;
$weeks = floor($diff->days/7) + 1;
$days = $diff->days + 1;
$turns_text = __("Turning",'ultimate-member');
if( $days < 7 ){
$data_array['birth_date'] = $turns_text . ' '. $days . ' ' . _n( 'day old', 'days old', $days, 'ultimate-member' );
}else if( $days >= 7 && $weeks < 4 ){
$data_array['birth_date'] = $turns_text . ' '. $weeks . ' ' . _n( 'week old', 'weeks old', $weeks, 'ultimate-member' );
}else if( $weeks >=4 && $months < 12 ){
$data_array['birth_date'] = $turns_text . ' '. $months . ' ' . _n( 'month old', 'months old', $months, 'ultimate-member' );
}else if( $months >= 12 || $years > 1 ){
$data_array['birth_date'] = $turns_text . ' '. $years . ' ' . _n( 'year old', 'years old', $years, 'ultimate-member' );
}
return $data_array;
}
@viprogress777
Copy link

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

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