• Resolved pgroenewegen

    (@pgroenewegen)


    I would like to show the birth date and the age at the same time. Currently there is only the option to show one or the other. My suggestion is to add an option for:
    <user friendly date (age)>

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Hi @pgroenewegen,

    Thanks for your suggestions.
    We will see if we can add this option in future plugin updates.

    Regards.

    juliengontard

    (@juliengontard)

    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 !

    Thread Starter pgroenewegen

    (@pgroenewegen)

    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.

    juliengontard

    (@juliengontard)

    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?

    juliengontard

    (@juliengontard)

    @ultimatemembersupport maybe you have an idea about this bug?

    Thread Starter pgroenewegen

    (@pgroenewegen)

    No idea. I’m just a user of the plugin. So I can’t help you with bugs.

    Plugin Contributor Champ Camba

    (@champsupertramp)

    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,

    juliengontard

    (@juliengontard)

    Thanks @champsupertramp !

    Is this code gonna display both the age and the birth date int the public user directory of Ultimate Member ?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Show both birth date and age’ is closed to new replies.