Skip to content

Instantly share code, notes, and snippets.

@jmdodd
Created April 16, 2012 23:26
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 jmdodd/2402288 to your computer and use it in GitHub Desktop.
Save jmdodd/2402288 to your computer and use it in GitHub Desktop.
Limit the BuddyPress datebox year range.
<?php
if ( ! function_exists( 'ucc_profile_field_datebox_year_range' ) ) {
function ucc_profile_field_datebox_year_range( $html, $type, $day, $month, $year, $field_id, $date ) {
if ( 'year' == $type ) {
$current_year = date( 'Y' );
$past_year = $current_year - 3;
$future_year = $current_year + 3;
$html = '';
$html .= '<option value=""' . selected( $year, '', false ) . '>----</option>';
for ( $i = $future_year; $i >= $past_year; $i-- ) {
$html .= '<option value="' . $i .'"' . selected( $year, $i, false ) . '>' . $i . '</option>';
}
}
return $html;
} }
add_filter( 'bp_get_the_profile_field_datebox', 'ucc_profile_field_datebox_year_range', 10, 7 );
/*
Copyright 2012 Jennifer M. Dodd (email: jmdodd@gmail.com)
Released under the GPLv2 (or later).
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment