Skip to content

Instantly share code, notes, and snippets.

@BoyetDgte
Last active November 5, 2020 04:03
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 BoyetDgte/074c33d41ab3489aea28bf9a99afe3cd to your computer and use it in GitHub Desktop.
Save BoyetDgte/074c33d41ab3489aea28bf9a99afe3cd to your computer and use it in GitHub Desktop.
Modify date range for BuddyPress Xprofile Custom Fields Type - Birthdate Selector (Starting at year 1930)
function custom_bxcft_birthdate_year($html, $type, $day, $month, $year, $field_id, $date) {
if($type == 'year'){
$html = '<option value=""' . selected( $year, '', false ) . '>----</option>';
for ( $i = date('Y', time()-60*60*24); $i > 1929; $i-- ) {
$html .= '<option value="' . $i .'"' . selected( $year, $i, false ) . '>' . $i . '</option>';
}
}
return $html;
}
add_filter( 'bp_get_the_profile_field_birthdate', 'custom_bxcft_birthdate_year',10,7);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment