跳到内容 跳到侧边栏

Waiting for author

Topic Tags: Compatibility

Overview of the issue

When using Ultimate Membership Pro with WPML, you might experience an issue where checkbox values used in member profiles and directory filters are not translatable. and prevents translated labels from appearing correctly on translated directory pages or forms.

Workaround

Please make sure you have a full backup of your site before proceeding.

1- Delete Incorrect Translations

  • Go to WPML > String Translation
  • Filter by Translation Complete
  • Search for strings under the field name [ihc_user_fields]
  • Select all these strings and delete them – they are value strings and should not be translated.

2- Modify Frontend Filter Template

  • Open: wp-content/plugins/indeed-membership-pro/public/views/listing_users-filter.php
  • Look for: Line 167 under the case ‘checkbox’
  • Replace:

    
    <?php
    foreach ($field['values'] as $v){
        if (is_array($get_value)){
            $checked = (in_array($v, $get_value)) ? 'checked' : '';
        } else {
            $checked = ($v==$get_value) ? 'checked' : '';
        }
        ?>
        <div class="iump-form-checkbox">
            <input type="checkbox" name="<?php echo esc_attr($field['name']);?>[]" value="<?php echo esc_attr(ihc_correct_text($v));?>" <?php echo esc_attr($checked);?> />
            <?php echo esc_html(ihc_correct_text($v));?>
        </div>
        <?php
    }
    ?>
    
    

    With:

    
    
    <?php
    foreach ($field['values'] as $v){
        if (is_array($get_value)){
            $checked = (in_array($v, $get_value)) ? 'checked' : '';
        } else {
            $checked = ($v==$get_value) ? 'checked' : '';
        }
    
        // WPML: Separate value and label
        $wpml_original_value = ihc_correct_text($v);
        $wpml_string_name = 'checkbox_option_' . $field['name']; 
        do_action( 'wpml_register_single_string', 'ihc', $wpml_string_name . '_' . sanitize_title($v), $wpml_original_value );
        $wpml_translated_label = apply_filters( 'wpml_translate_single_string', $wpml_original_value, 'ihc', $wpml_string_name . '_' . sanitize_title($v) );
    ?>
        <div class="iump-form-checkbox">
            <input type="checkbox" name="<?php echo esc_attr($field['name']);?>[]" value="<?php echo esc_attr(ihc_correct_text($v));?>" <?php echo esc_attr($checked);?> />
            <?php echo esc_html($wpml_translated_label); ?>
        </div>
    <?php
    }
    ?>
    

3- Fix Registration Form Checkbox Labels

  • Open: wp-content/plugins/indeed-membership-pro/classes/IndeedForms.php
  • Look for: The checkbox function (around line 129)
  • Replace:

    
    $output .= ihc_correct_text( $v );
    

    With:

    
    $output .= __( ihc_correct_text( $v ), 'ihc' );</ul>
    

    4- Trigger String Registration

    • Visit the directory page on the frontend to load new strings.
    • Go to WPML > String Translation and translate only the newly registered strings under the “ihc” domain (named like checkbox_option_name).

发表回复

保持话题相关并尊重他人。如果您需要与此帖子无关的问题帮助,请使用我们的支持论坛开始聊天或提交工单。

您可以使用这些标签:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>