Skip Navigation

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

Problem:
You are experiencing an issue where you cannot save or edit translations due to an error message: 'Updating failed. The response is not a valid JSON response.' This problem is likely related to the reverse proxy settings on your live website.
Solution:
First, ensure you have a full backup of your site as the settings involved are sensitive. Then, follow these steps:
1. Add the following code to your theme's functions.php file:

function test_remove_homefilter() {<br />if (is_admin()) {<br />global $wp_filter;<br />if (isset($wp_filter['home_url']->callbacks[-10])) {<br />foreach ($wp_filter['home_url']->callbacks[-10] as $key => $value) {<br />if (str_contains($key, 'home_url_filter')) {<br />remove_filter('home_url', $key, -10);<br />}<br />}<br />}<br />}<br />}<br />add_action('admin_init', 'test_remove_homefilter');

2. If the issue persists, add the following rewrite rule to your server's configuration to correct the request paths:

location ~ ^/[a-z]{2}/wp-json/(.*) {<br />    rewrite ^/[a-z]{2}/wp-json/(.*) /wp-json/$1 permanent;<br />}

If these steps do not resolve the issue or if the solution seems outdated or not applicable to your case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket.

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 3 replies, has 0 voices.

Last updated by Lucas Vidal de Andrade 6 months, 2 weeks ago.

Assisted by: Lucas Vidal de Andrade.

Author Posts
October 30, 2024 at 12:52 pm

stefand-43

The issue is very likely related to the reverse proxy set in the live website. We could confirm that by analyzing a staging version and a local copy, where the issue is not happening. The local copy is an exact fresh copy of the live website.

Background of the issue:
I am trying to translate a page/article into another language (French, German, Spanish, etc.).

Symptoms:
An error message appears: 'Updating failed. The response is not a valid JSON response.' I can't save or edit.

Questions:
Why am I receiving a 'Updating failed. The response is not a valid JSON response.' error?
How can I resolve this issue to save or edit translations?

October 30, 2024 at 1:51 pm
October 30, 2024 at 1:59 pm #16347601

Lucas Vidal de Andrade
WPML Supporter since 11/2023

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there, one more thing.

Can you please provide as much information as possible, on how the proxy was set up?

"I would recommend that the client have dialogue with their host check the proxy settings as well as to check the access logs for their proxy server to see the routing of the connections."

Let me know.

November 4, 2024 at 4:56 pm #16362532

stefand-43

Hey Lucas,

Sorry for the late answer.

You will be able to find all our details of setup and configuration on the following page: hidden link

Do not hesitate to ask for further informations!

November 4, 2024 at 6:31 pm #16362891

Lucas Vidal de Andrade
WPML Supporter since 11/2023

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Thank you so much for sharing. I've shared the information with our devs and will get back to you as soon as I hear from them.

November 12, 2024 at 1:42 pm #16392942

Lucas Vidal de Andrade
WPML Supporter since 11/2023

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there

I got feedback from our devs. Since we cannot directly test the solution, please make sure to have a full backup before proceeding. Those settings are sensitive and can lead to issues.

1. Add the following code to your theme's functions.php:

function test_remove_homefilter() {
	if ( is_admin() ) {
		global $wp_filter;
		if ( isset( $wp_filter['home_url']->callbacks[ - 10 ] ) ) {
			foreach ( $wp_filter['home_url']->callbacks[ - 10 ] as $key => $value ) {
				if ( str_contains( $key, 'home_url_filter' ) ) {
					remove_filter( 'home_url', $key, - 10 );
				}
			}
		}
	}
}
add_action( 'admin_init', 'test_remove_homefilter' );

2. If that does not help, please add the rewrite rule below to your server. It seems that the requests are incorrectly passed to e.g. hidden link instead of hidden link. That seems to be the issue.

location ~ ^/[a-z]{2}/wp-json/(.*) {
    rewrite ^/[a-z]{2}/wp-json/(.*) /wp-json/$1 permanent;
}

Let me know how it goes.