Skip to:

Opened 16 months ago

#8083 new enhancement

Add Age option to BP Xprofile Databox

Reported by: Venutius Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Extended Profile Keywords:


The BP datebox xProfile field has an elapsed time option but not an age option. I'd like to suggest we fill this missing hole as many BP's would probably prefer to display their age rather than their DoB. I think this could be an easy add, we just need to duplicate the elapsed time options and update them for age. I think the changes need to be made in a couple of places:

In class-bp-xprofile-field-type-datebox.php:

Line 478 insert:

<div class="bp-date-format-option">
    <label for="date-format-age">
	<input type="radio" name="field-settings[date_format]" id="date-format-age" <?php checked( 'age', $settings['date_format'] ); ?> value="age" aria-describedby="date-format-age-setting" />
	<span class="date-format-label" id="date-format-age-setting"><?php esc_html_e( 'Age', 'bp-xprofile-age-field' ); ?></span> <?php _e( '<code>4 years old</code>', 'bp-xprofile-age-field' ); ?>

On line 600 insert:

case 'age' :
    add_filter( 'bp_core_time_since_ago_text', function($text){ return '%s old'; } );
    $formatted = bp_core_time_since( $field_value );
    remove_filter( 'bp_core_time_since_ago_text', function($text){ return '%s old'; } );

Change History (0)

Note: See TracTickets for help on using tickets.