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 thread is resolved. Here is a description of the problem and solution.

Problem:
I try to trigger a Convertplus popup depending on the current language page of the user. But french Popup is triggered on the whole website.

Solution:

function cp_callback_function( $display, $style_id ) {

if( $style_id == 'cp_id_23423' && ICL_LANGUAGE_CODE == 'en') return true;
if( $style_id == 'cp_id_23424' && ICL_LANGUAGE_CODE == 'fr') return true;

return $display;

}
add_filter( 'cp_target_page_settings', 'cp_callback_function', 10, 2

Relevant Documentation:
https://wpml.org/wpml-hook/wpml_current_language/
https://theme.co/apex/forum/t/is-convertplus-compatible-with-wpml-how-to-translate/24945/2

This topic contains 3 replies, has 2 voices.

Last updated by Andrés 1 year, 4 months ago.

Assigned support staff: Andrés.

Author Posts
May 2, 2018 at 11:42 am #1930057

sebastienL-20

Tell us what you are trying to do?
--> I try to trigger a popup depending on the current language page of the user.
--> Only french Popup is trigered on the whole website.
--> PHP code below

Is there any documentation that you are following?
--> Here is the best link I found : hidden link

Is there a similar example that we can see?
--> I didn't find more tickets talking about this ConvertPlus plugin.

What is the link to your site?
--> hidden link

PHP code integrated in function.php currently :

// WPML popup ecommerce
function cp_callback_function( $display, $style_id ) {

if( $display ) {
// Replace style id with your style ID
if( $style_id == 'cp_id_6ba97' ) {

// get current language code
$language_code = en;

// replace fr with your language code
if( $language_code == 'en' ) {
$display = true;
} else {
$display = false;
}

}
}

return $display;
}
add_filter( 'cp_target_page_settings', 'cp_callback_function', 10, 3 );

May 2, 2018 at 1:41 pm #1933402

Andrés
Supporter

Languages: English (English ) Spanish (Español ) French (Français )

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

Bonjour Sebastien,

Bienvenue à nouveau. 🙂

Si je lis correctement votre code, il affiche le pop-up cp_id_6ba97 en français et rien dans les autres langues.

Si cela est votre objective, je vous recommande de l'adapter pour le code à continuation :

function cp_callback_function( $display, $style_id ) {
     
     if( $display ) {
        // Replace style id with your style ID
        if( $style_id == 'cp_id_6ba97' ) {
     
            // get current language code
            $language_code = apply_filters( 'wpml_current_language', NULL );
                    
                    // replace fr with your language code 
            if( $language_code == 'fr' ) {
                $display = true;
            } else {
                $display = false;
            }
     
        }
    }
 
    return $display;
}
add_filter( 'cp_target_page_settings', 'cp_callback_function', 10, 3 );

Si vous souhaitez afficher des pop-ups selon la langue, je vous recommande de regarder le lien à continuation :
hidden link

2. Pour pouvoir vous aider plus rapidement, j’ai activé l’information de debug pour ce ticket. Merci de regarder ce lien pour savoir comment obtenir plus d’information de votre site et nous la fournir.
https://wpml.org/fr/faq/comment-fournir-des-informations-de-debogage-pour-une-assistance-plus-rapide/

Documentation :
https://wpml.org/wpml-hook/wpml_current_language/

Cordialement,
Andrés

May 6, 2018 at 8:11 am #1996137

sebastienL-20

Hello Andrès,

I used the code in the link you suggested. I adapted it for my website and it works gret now 🙂

function cp_callback_function( $display, $style_id ) {

if( $style_id == 'cp_id_23423' && ICL_LANGUAGE_CODE == 'en') return true;
if( $style_id == 'cp_id_23424' && ICL_LANGUAGE_CODE == 'fr') return true;

return $display;

}
add_filter( 'cp_target_page_settings', 'cp_callback_function', 10, 2 );

Thank you for your help.

May 6, 2018 at 8:28 am #1996143

Andrés
Supporter

Languages: English (English ) Spanish (Español ) French (Français )

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

That's great! 🙂
Have a nice day.