WPML

Tổng quan về sự cố

Khi sử dụng WP User Manager để thêm các trường tùy chỉnh vào hồ sơ, bạn có thể gặp phải sự cố sau: các tùy chọn từ các trường tùy chỉnh chọn nhiều không thể dịch được trong Dịch chuỗi của WPML.

Giải pháp tạm thời

Vui lòng đảm bảo bạn có một bản sao lưu toàn bộ trang web của mình trước khi tiếp tục.

1. Sửa plugin tích hợp (WPUM-WPML)

  • Mở tệp …/wp-content/plugins/wpum-wpml/includes/class-wpum-wpml-fields.php.
  • Tìm dòng 20.
  • Thay thế:
    PHP
    add_action( 'update_wpum_field_meta', array( $this, 'update_meta_strings' ), 10, 4 );
  • Bằng:
    PHP
    add_action( 'updated_wpum_field_meta', array( $this, 'update_meta_strings' ), 10, 4 );
  • Sau đó, đi tới Người dùngTrường tùy chỉnh, chỉnh sửa ít nhất một trong các tùy chọn của trường chọn nhiều, rồi điều hướng đến WPMLDịch chuỗi để dịch các giá trị.

2. Sửa đầu ra trên giao diện người dùng trong WP User Manager

  • Mở tệp …/wp-content/plugins/wp-user-manager/includes/fields/types/class-wpum-field-multiselect.php.
  • Tìm dòng 56.
  • Thay thế toàn bộ hàm get_formatted_output() bằng:
    PHP
    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 );
    }

Tất cả lỗi đã ghi nhận

Cần trợ giúp với vấn đề này?

Đặt một câu hỏi hỗ trợ và chúng tôi sẽ cùng bạn xem xét vấn đề này.