Skip to content Skip to sidebar

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

Problem:
You are using the AffiliateWP 'Affiliate Portal' with WPML on a bilingual site and encountering issues where only the language in which settings are saved shows the Portal layout correctly. Switching to the German backend shows 'None' in dropdowns, and saving settings in one language clears them in another.
Solution:
1. Ensure you back up your site before making changes.
2. Resave all your 'affwp_settings' in English first.
3. Add this code to your functions.php file to ensure the affiliate page ID is correctly translated:

add_filter( 'affwp_affiliate_area_page_id', function( $affiliate_page_id ) {<br />    if ( defined( 'WPML_PLUGIN_FILE' ) ) {<br />        $affiliate_page_id = apply_filters( 'wpml_object_id', $affiliate_page_id, 'page', true );<br />    }<br />    return $affiliate_page_id;<br />}, 10, 1 );

4. To translate menu link titles and URLs, modify the .../wp-content/plugins/affiliatewp-affiliate-portal/includes/core/class-menu-links.php file as follows:

foreach ( $menu_links as $index => &$link ) {<br />    if ( ! empty( $link['label'] ) ) {<br />        do_action( 'wpml_register_single_string', 'affiliatewp-portal-menu', 'portal_menu_link_label_' . $index, $link['label'] );<br />        $link['label'] = apply_filters( 'wpml_translate_single_string', $link['label'], 'affiliatewp-portal-menu', 'portal_menu_link_label_' . $index );<br />    }<br />}

5. Resave settings under "AffiliateWP > Settings > Affiliate Portal" and translate labels via "WPML > String Translation".

We also published erratas about these issues.
https://wpml.org/errata/affiliatewp-portal-page-settings-reset-when-switching-languages/
https://wpml.org/errata/affiliatewp-portal-custom-menu-link-labels-not-translated/

If this solution does not resolve your issue or seems outdated, please check related known issues, verify the version of the permanent fix, and confirm that you have installed the latest versions of themes and plugins. If needed, do not hesitate to 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 6 replies, has 1 voice.

Last updated by Itamar 3 weeks, 5 days ago.

Assisted by: Itamar.

Author Posts
June 17, 2025 at 1:38 am #17140470

kevinR-12

Background of the issue:
I am trying to use the AffiliateWP 'Affiliate Portal' with WPML on a bilingual site where English is the default language and German is the secondary language. In the backend under AffiliateWP > Settings > Affiliates, there are dropdowns to assign the Affiliate Account, Login, and Registration pages. When I’m in the English backend (&lang=en), I can assign the correct pages, and the portal shows fine on /affiliate-area/. However, when switching to the German backend (&lang=de), those dropdowns show 'None' as selected. If I assign the correct translated pages for DE (/de/partner-bereich/ etc.) and save, the English settings are cleared. This issue can be seen on the following pages: EN: hidden link DE: hidden link.

Symptoms:
Only the language where the settings are saved (EN or DE) displays the Portal layout. The other language reverts to the default Affiliate Area layout and the page dropdowns are cleared.

Questions:
How can I ensure that the Affiliate Portal layout is displayed in both languages using the translated Affiliate Area pages in WPML?
Why do the page dropdowns show 'None' when switching to the German backend?

June 19, 2025 at 3:42 pm #17151541

Laura
WPML Supporter since 05/2018

Languages: English (English ) Italian (Italiano )

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

Hi,

thanks for contacting us.

Can you please check if this errata helps?

June 20, 2025 at 10:27 am #17153798

kevinR-12

Hi,

Thanks for your reply and for sharing the errata.

I did review the workaround you suggested, but it appears to apply only to the **classic Affiliate Area**, which uses the `[affiliate_area]` shortcode and standard WordPress page templates. That snippet filters `affwp_affiliate_area_page_id`, which the **Affiliate Portal Addon does not use**.

The Affiliate Portal is a **JavaScript-based, full-screen experience** that loads via its own scripts (`core.js`, `sdk.js`, etc.) and uses the REST API under `/wp-json/affwp/v2/portal/...`.

The issue is that under *AffiliateWP > Settings > Affiliates*, I can only assign a **single page globally**. If I assign the English page, the portal works at `/affiliate-area/`. If I then assign the German translated page (`/de/partner-bereich/`), the previous assignment is overwritten, and the portal only works in German.

So the core problem is: **AffiliateWP does not store page assignments in a language-aware way**, and the portal does not respect WPML translations of that assigned page.

Please escalate this to a developer familiar with WPML language mapping and how filters like `affwp_affiliate_area_page_id` relate (or don’t relate) to the Portal Addon. This needs a deeper compatibility layer – one that can dynamically assign the correct portal page per language.

Thanks again,
Kevin

June 23, 2025 at 7:41 pm #17162375

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi, Kevin.

I'll continue to help you with this issue.

Please note what we state on the plugins page here:
https://wpml.org/plugin/affiliatewp/

AffiliateWP is partially compatible with WPML and we are currently working with their team on finalizing the integration. Please see the documentation for more details.

Further information can be found on their website here: hidden link
For the mentioned Custom Link Generator issue, we have a workaround here.
https://wpml.org/errata/affiliatewp-custom-link-generator-only-works-in-default-language/

If none of the above helps you to solve the problem, then we need to replicate this issue on a fresh WordPress installation. Then I'll be able to escalate it to our compatibility team. To achieve this, I created a test website with a clean WordPress installation. You can access it through this link:

hidden link

With this link, you'll be directly logged in.

Could you please install the AffiliateWP plugin and see if the issue is replicable on a clean WordPress installation?

I already configured WPML to have English as the default language and German as the second language.

Please also make sure that you are installing the latest version of the plugin.

When everything is finished and you can replicate the problem, please let us know.

Important! Do not import your site to the test site. We must replicate the problem on a fresh, clean WordPress installation.

Regards,
Itamar.

June 24, 2025 at 12:32 am #17162671

kevinR-12

Dear Itamar,

thanks a lot for the willingness to help provide better compatibility with AffiliateWP and for providing the sandbox.

I already configured everything and recorded a screencast to show you how you can reproduce the issue: hidden link

Please let me know if you have any further questions.

Warm regards,

Kevin

June 24, 2025 at 11:01 am #17164388

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi, Kevin.

Thanks a lot for replicating the problem on the sandbox site. Additionally, I greatly appreciate the video you shared, as it is beneficial for understanding the situation.

I attempted to find a workaround for this issue by translating system fields using the IDs of the selected page; however, it was unsuccessful. Therefore, I escalated this issue to our compatibility team. I'll keep you updated on any news regarding this issue.

I want to set expectations regarding this issue. We'll do our best to help you with this issue. If our compatibility team finds a workaround, we will share it with you. However, the permanent solution to this issue may not be solely within our control, and we will need the cooperation of the AffiliateWP authors to address this problem.

I appreciate your patience.
Itamar.

July 2, 2025 at 10:09 am #17192135

Itamar
WPML Supporter since 02/2016

Languages: English (English )

Timezone: Asia/Jerusalem (GMT+03:00)

Hi,

Our compatibility team has shared workarounds for those cases.

1. Take a backup of your site in case something goes wrong.

2. Resave all your affwp_settings settings in English first.

3. Add the following code to your functions.php file:

add_filter( 'affwp_affiliate_area_page_id', function( $affiliate_page_id ) {
    if ( defined( 'WPML_PLUGIN_FILE' ) ) {
        $affiliate_page_id = apply_filters( 'wpml_object_id', $affiliate_page_id, 'page', true );
    }
    return $affiliate_page_id;
}, 10, 1 );

Regarding your request to translate menu link titles and URLs via WPML. Our compatibility team adds the following.

- The URLs will be automatically translated by WPML since you can only pick internal pages.

- For the label, follow this workaround

1. Take a backup of your site in case something goes wrong.

2. Open the .../wp-content/plugins/affiliatewp-affiliate-portal/includes/core/class-menu-links.php file with a code editor.

3. Look for line 102.
Replace:

		// filter only menu links with a page.
		$menu_links = array_filter(
			$menu_links,
			function( $menu_link) {
				return ! empty( $menu_link['id'] );
			}
		);

With:

		// filter only menu links with a page.
		$menu_links = array_filter(
			$menu_links,
			function( $menu_link) {
				return ! empty( $menu_link['id'] );
			}
		);
		// WPML Workaround for compsupp-8049 - Register menu links labels with WPML
		foreach ( $menu_links as $index => &$link ) {
			if ( ! empty( $link['label'] ) ) {
				do_action( 'wpml_register_single_string', 'affiliatewp-portal-menu', 'portal_menu_link_label_' . $index, $link['label'] );
				$link['label'] = apply_filters( 'wpml_translate_single_string', $link['label'], 'affiliatewp-portal-menu', 'portal_menu_link_label_' . $index );
			}
		}

4. Go back to "AffiliateWP > Settings > Affiliate Portal" and resave.

5. Then go to "WPML > String Translation" to translate those labels.

**** Important! Please make a full site backup (files and DB) before you proceed with those steps****

Please try this and let us know how it goes.

Regards,
Itamar.