Hi @pgroenewegen,
Thanks for your suggestions.
We will see if we can add this option in future plugin updates.
Regards.
Hey @pgroenewegen where do you find the settings where you choose to display either the age or date of birth ? Can’t find it !
Thanks !
In your Ultimate Member profile form, go to the birth date field. There is an option called ‘displayed date format’ on the right column. It has 2 options: ‘show full date’, which displays the date in the format you selected in ‘date – user friendly format’. But it also has the option ‘show years only’ which shows the calculated age.
Thanks for your reply,
I’ve tried that but it didn’t change anything and still displays the age. Do I need to regenerate users data somewhere?
@ultimatemembersupport maybe you have an idea about this bug?
No idea. I’m just a user of the plugin. So I can’t help you with bugs.
Hi @pgroenewegen
You can try this custom code to add both age and birth date:
function um_profile_field_filter_hook__date( $value, $data ) {
if ( ! $value ) {
return '';
}
if ( isset( $data['pretty_format'] ) && $data['pretty_format'] == 1 ) {
$value = UM()->datetime()->get_age( $value );
} else {
$format = empty( $data['format_custom'] ) ? $data['format'] : $data['format_custom'];
$value = date_i18n( $format, strtotime( $value ) );
}
return $value;
}
add_filter( 'um_profile_field_filter_hook__date', 'um_custom_profile_field_filter_hook__date', 99, 2 );function um_profile_field_filter_hook__date( $value, $data ) {
if ( ! $value ) {
return '';
}
$value .= UM()->datetime()->get_age( $value );
$value .= " ".date_i18n( $format, strtotime( $value ) );
return $value;
}
add_filter( 'um_profile_field_filter_hook__date', 'um_custom_profile_field_filter_hook__date', 99, 2 );
remove_filter( 'um_profile_field_filter_hook__date', 'um_profile_field_filter_hook__date', 99, 2 );
Ensure that you’ve created a full backup of your site before you add the above code to your theme’s function.php file.
Regards,
Thanks @champsupertramp !
Is this code gonna display both the age and the birth date int the public user directory of Ultimate Member ?