Created
April 16, 2012 23:26
-
-
Save jmdodd/2402288 to your computer and use it in GitHub Desktop.
Limit the BuddyPress datebox year range.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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