Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WPML + Ultimate Member date translation
<?php
add_filter( 'option_date_format', 'translate_date_format', 10, 1 );
function translate_date_format( $format ) {
do_action( 'wpml_register_single_string', 'Date Formats', 'date format', $format );
$format = apply_filters( 'wpml_translate_single_string', $format, 'Date Formats', 'date format' );
return $format;
}
​// remove the existing filter on init
remove_filter( 'um_profile_field_filter_hook__user_registered', 'um_profile_field_filter_hook__user_registered', 99 );
​// add your custom function and attach the filter.
add_filter( 'um_profile_field_filter_hook__user_registered', 'um_custom__user_registered', 100, 2 );
function um_custom__user_registered( $value, $data ) {
$value = strtotime( $value );
$date_format = get_option( 'date_format' );
$value = sprintf( __( 'Joined %s', 'ultimatemember' ), date_i18n( $date_format, $value ) );
return $value;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment