Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
If you're experiencing a 500 Internal Server Error when using WPForms, WPML, and WPForms multilang with a Repeater containing Select form elements, the issue might be related to how array keys are handled in the Notifications.php file of the WPML-WPForms integration.
Solution:
We recommend modifying the code in the Notifications.php file. First, locate line 92 and replace the existing code block:

foreach ( $fields as $key => &$field ) {
    $field['name'] = $formPostFields[ $key ]['label'];
    $entryFields   = Obj::propOr( [], 'fields', $entry );
    if ( array_key_exists( $key, $entryFields ) ) {
        $field['value'] = $this->getFieldValue( $field, $entry['fields'][ $key ], $formPostFields[ $key ], $translatedFields[ $key ] );
    }
}

with:

foreach ( $fields as $key => &$field ) {
    $key = strpos( $key, '_' ) !== false ? substr( $key, 0, strpos( $key, '_' ) ) : $key;
    $field['name'] = $formPostFields[ $key ]['label'];
    $entryFields   = Obj::propOr( [], 'fields', $entry );
    if ( array_key_exists( $key, $entryFields ) ) {
        $field['value'] = $this->getFieldValue( $field, $entry['fields'][ $key ], $formPostFields[ $key ], $translatedFields[ $key ] );
    }
}

Please ensure to test this change on a staging site before applying it to your live environment.

If this solution does not resolve your issue, or if it seems outdated or irrelevant to your specific case, we highly recommend opening a new support ticket. Also, check the related known issues and confirm that you have installed the latest versions of themes and plugins.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: ,

This topic contains 0 reply, has 0 voices.

Last updated by Kor 2 months, 3 weeks ago.

Assisted by: Kor.

Author Posts
March 7, 2025 at 11:04 am #16787720

dominikN-6

Hey Kor, thanks for update. Yeah, that's OK, I just wanted to be really sure we will not loose any further updates we do.

March 10, 2025 at 6:03 am #16794378

Kor
WPML Supporter since 08/2022

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Thanks for your patience. I've received feedback from our 2nd Tier Support and they shared a workaround with us. However, please test this workaround on a test/staging site first before applying it to your production site. Please let me know how it goes.

Workaround
Open the .../wp-content/plugins/wpml-wpforms/classes/Hooks/WpForms/Notifications.php file

Look for line 92

Replace:

foreach ( $fields as $key => &$field ) {
    $field['name'] = $formPostFields[ $key ]['label'];
    $entryFields   = Obj::propOr( [], 'fields', $entry );
    if ( array_key_exists( $key, $entryFields ) ) {
        $field['value'] = $this->getFieldValue( $field, $entry['fields'][ $key ], $formPostFields[ $key ], $translatedFields[ $key ] );
    }
}

With:

foreach ( $fields as $key => &$field ) {
    $key = strpos( $key, '_' ) !== false ? substr( $key, 0, strpos( $key, '_' ) ) : $key;
    $field['name'] = $formPostFields[ $key ]['label'];
    $entryFields   = Obj::propOr( [], 'fields', $entry );
    if ( array_key_exists( $key, $entryFields ) ) {
        $field['value'] = $this->getFieldValue( $field, $entry['fields'][ $key ], $formPostFields[ $key ], $translatedFields[ $key ] );
    }
}
March 10, 2025 at 9:06 am #16795113

dominikN-6

Good morning Kor and thank you for your reply. Now, on a first sight, it seems working. We will test it more widely with more possible combinations and languages and I'll get back to you to confirm/update how it goes.
Thank you once more for your assistance and have a great day! Best regards.

March 10, 2025 at 9:07 am #16795119

Kor
WPML Supporter since 08/2022

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Alright then, let me know how it goes.