WPML

Overview of the Issue

When using WP User Manager to add custom fields to profiles, you might experience the following issue: options from multi-select custom fields are not translatable in WPML’s String Translation.

Workaround

Please, make sure of having a full site backup of your site before proceeding.

1. Fix the Integration Plugin (WPUM-WPML)

  • Open the …/wp-content/plugins/wpum-wpml/includes/class-wpum-wpml-fields.php file.
  • Look for line 20.
  • Replace:
    add_action( 'update_wpum_field_meta', array( $this, 'update_meta_strings' ), 10, 4 );
  • With:
    add_action( 'updated_wpum_field_meta', array( $this, 'update_meta_strings' ), 10, 4 );
  • After that, go to UsersCustom fields, edit at least one of the multi-select field options, then navigate to WPMLString Translation to translate the values.

2. Fix the Front-End Output in WP User Manager

  • Open the …/wp-content/plugins/wp-user-manager/includes/fields/types/class-wpum-field-multiselect.php file.
  • Look for line 56.
  • Replace the entire get_formatted_output() function with:
    public function get_formatted_output( $field, $value ) {
    
        $stored_field_options = $field->get_meta( 'dropdown_options' );
        $stored_options       = array();
        $stored_index         = array();
    
        // Keep the plugin's own guard.
        if ( ! is_array( $stored_field_options ) ) {
            return '';
        }
    
        foreach ( $stored_field_options as $key => $stored_option ) {
            $val                    = isset( $stored_option['value'] ) ? $stored_option['value'] : $key;
            $lbl                    = isset( $stored_option['label'] ) ? $stored_option['label'] : '';
            $stored_options[ $val ] = $lbl;
            $stored_index[ $val ]   = $key;
        }
    
        $values = array();
    
        // Keep the plugin's (array) cast.
        foreach ( (array) $value as $user_stored_value ) {
            if ( ! isset( $stored_options[ $user_stored_value ] ) ) {
                continue;
            }
    
            $label = $stored_options[ $user_stored_value ];
            $index = isset( $stored_index[ $user_stored_value ] ) ? $stored_index[ $user_stored_value ] : 0;
    
            $translated_label = apply_filters(
                'wpml_translate_single_string',
                $label,
                'wpum-fields-wpum-field-' . $field->get_ID(),
                'wpum-field-dropdown_options_' . $index
            );
    
            $values[] = $translated_label;
        }
    
        return implode( ', ', $values );
    }

Need Help with This Issue?

Ask a support question and we’ll look into it with you.

Ask a support question

All known issues