Created
May 9, 2017 00:29
-
-
Save champsupertramp/d5401abccb12e3b535c9b52a1f75a75e to your computer and use it in GitHub Desktop.
WPML + Ultimate Member date translation
This file contains hidden or 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 | |
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