Skip to content Skip to sidebar

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

Problem:
You are experiencing issues with editing a page on your multisite setup, where attempting to edit the page forces a login screen, and subsequent login redirects you back to a different domain.
Solution:
We recommend checking the 'Automatically log in and log out users across all domains' option in your WPML settings. This setting can be found under WPML > Languages in your WordPress admin area. Enabling this option should resolve the issue of being redirected after logging in. If you need to log in again when trying to edit the page, this should be expected, but it should allow you to proceed with editing without further redirections.

Please note that this solution might be outdated or not applicable to your specific case. We highly recommend checking the related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the issue 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.

This topic contains 9 replies, has 2 voices.

Last updated by Bruno Kos 9 months, 2 weeks ago.

Assisted by: Bruno Kos.

Author Posts
October 18, 2024 at 7:08 am #16302842

dominikC-4

Background of the issue:
I have a multisite with two domains: 360px.pl and 360care.pl. In the second domain 360care.pl, I have WPML with separate domains (360px.pl and 360care.site). I want to edit the page hidden link. I have a sunrise.php file like in your documentation.

Symptoms:
When I try to edit the page hidden link, the system forces a login page. After logging in, the system redirects me to 360care.pl.

Questions:
Why does the system force a login page when I try to edit hidden link?
Why am I redirected to 360care.pl after logging in?

October 21, 2024 at 6:52 am #16310391

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

Thank you for contacting WPML support!

So you set sunrise.php like this?
https://wpml.org/documentation/support/multisite-support/#using-languages-in-domains-on-multisite

What if you try something like this:

if ( isset( $_SERVER[ 'HTTP_HOST' ] ) ) {
    // Get the current domain
    $domain = $_SERVER['HTTP_HOST'];

    // Define a mapping of domains to site IDs in your multisite
    $domain_mapping = array(
        '360care.pl' => 1,        // Blog ID 1 for 360care.pl
        '360care.site' => 2,      // Blog ID 2 for 360care.site
        '360px.pl' => 3,          // Blog ID 3 for 360px.pl
    );

    // Switch to the corresponding site based on the current domain
    if ( array_key_exists( $domain, $domain_mapping ) ) {
        switch_to_blog( $domain_mapping[ $domain ] );
    }
}

Does it help?

Regards,
Bruno Kos

October 21, 2024 at 8:53 am #16311002

dominikC-4

Where should I put that code ? To the sunrise.php ? Which line ? Or maybe to the functions.php ?

October 21, 2024 at 9:10 am #16311084

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+02:00)

The code I provided should be placed in the sunrise.php file, not in functions.php, because sunrise.php is specifically designed for handling domain mapping in WordPress multisite setups.

Also, ensure that your wp-config.php file has the following line to enable sunrise and domain mapping:

define( 'SUNRISE', 'on' );
October 23, 2024 at 7:31 am #16320200

dominikC-4

Now I can't edit site using elementor.

October 23, 2024 at 9:21 am #16320901

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+02:00)

Do you mean after:

	
define( 'SUNRISE', 'on' );

Or the previous code I suggested?

What happens when you try opening Elementor, any error in the console? Does it work in site default language, or translated language only?

October 23, 2024 at 12:52 pm #16321871

dominikC-4

Previous one.
This time when I try to edit elementor, system redirects me to the Homepage of 360px.agency. Link to edit this page has hidden link domain, so that's correct.
hidden link

October 23, 2024 at 1:02 pm #16321924

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+02:00)

I see. Can you revert this then, remove my proposed code and provide me with WordPress credentials so I could check this myself?

October 23, 2024 at 1:10 pm #16321955

dominikC-4

Changes removed. I set wrong Path. Shuld be /domains/360px.pl/public_html

October 24, 2024 at 7:00 am #16324428

Bruno Kos
WPML Supporter since 12/2018

Languages: English (English ) German (Deutsch ) French (Français )

Timezone: Europe/Zagreb (GMT+02:00)

We found that the issue may be "Automatycznie loguj i wyloguj użytkowników we wszystkich domenach " option which was not enabled on hidden link.

You may need to login once again when trying to open editing of this page, but it should work.

Clipboard_10-24-2024_01.png
October 24, 2024 at 7:09 am #16324451

dominikC-4

I've checked this option and works fine. Thanks a lot!