• Resolved mirabela1982

    (@mirabela1982)


    Hi,

    I have a multilanguage site and I want to display the Newsletter subscription message in both languages and subscribe people to different Mailchimp lists. I want to have the checkbox just under the “Privacy Policy” checkbox.

    If I use just this code [yikes_mailchimp_checkbox] everything is fine, but I can only show the message in one language.

    When I use the shortcode in Contact Form 7, I just can see the shortcode on the live website.

    Does anybody know the solution?

    Thanks,
    Mireia

    • This topic was modified 5 years, 9 months ago by mirabela1982.

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 29 total)
  • Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Hi Mireia,

    You can only use the [yikes_mailchimp_checkbox] shortcode inside of CF7.

    In order to change the checkbox label based on the language of the site, we’ll need to use a filter function. What language is the checkbox label text in? If you have the default label as English, this function will change it when not on the /en/ domain.

    Are you familiar with adding PHP filter functions to your site?

    add_filter( 'yikes_mailchimp_checkbox_integration_checkbox_label', 'yikes_customize_cf7_checkbox_label', 10, 3 );
    
    function yikes_customize_cf7_checkbox_label( $label, $type, $checkbox_options ) {
    	if ( $type !== 'contact_form_7' ) {
    		return $label;
    	}
    
    	$is_english = strpos( $_SERVER['REQUEST_URI'], '/en/' ) !== false;
    
    	if ( $is_english ) {
    		return $label;
    	} else {
    		return 'Hola :)';
    	}
    }

    Let me know.

    Thank you,
    Kevin.

    Thread Starter mirabela1982

    (@mirabela1982)

    Hi Kevin,

    Thank you very much for your fast reply.

    1) Where do I have to paste this code?

    2) This code is going to help to subscribe users to correct Mailchimp list in function of the language?

    Thanks,
    Mireia

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Hi Mireia,

    This code will only change the language. If you want to change the list, we’ll need another function. Do you want to start with just trying to change the language and if that is successful we can work on changing the list too?

    The best place for this code is your child theme’s functions.php file. If you’re not using a child theme, you can use your theme’s functions.php file or a plugin like ?My Custom Functions.

    If you’re not familiar with adding code to your site, I think using the plugin is probably the best idea because it provides some safety measures.

    Thread Starter mirabela1982

    (@mirabela1982)

    It worked. Now, what would be the next step, Kevin?

    BTW, as you can see, there is no space between the checkbox and the text. How can I add a space?

    Thanks

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    That was quick! Nice.

    For the styling, can you wrap your privacy policy checkbox in a <p> tag? I think you can do that in CF7. That will automatically give it a bottom margin.

    To set up the checkbox to send data to different lists, you’ll need your English Mailchimp list ID. You can get your list ID by going to Mailchimp.com or by going to the form builder in our plugin, clicking view list (https://imgur.com/a/fCNC0oL) and then copying the list id from the URL (https://imgur.com/a/wmvFqOR).

    Also, you should configure the integration so it is only sending data to the Spanish list. Then we’ll change that single list ID to English if the subscriber is on the English version of the site.

    Replace your list id with the englishlist string (make sure to keep the quotes around it).

    add_filter( 'yikes-mailchimp-checkbox-integration-list-id', 'customize_cf7_integration_list_id', 10, 3 );
    
    function customize_cf7_integration_list_id( $list_id, $data, $type ) {
    
    	// Make sure we're dealing with the CF7 integration
    	if ( $type !== 'contact_form_7' ) {
    		return $list_id;
    	}
    
    	// Get the current language from the URL
    
    	// English!
    	if ( isset( $_SERVER['REQUEST_URI'] ) && strpos( $_SERVER['REQUEST_URI'], '/en/' ) !== false ) {
    		return 'englishlistid'; // English List ID
    	}
    
    	// If we can't find any language specified, return the default list id.
    	return $list_id;
    }

    Cheers,
    Kevin.

    Thread Starter mirabela1982

    (@mirabela1982)

    Hi Kevin,

    I updated your code:

    add_filter( 'yikes-mailchimp-checkbox-integration-list-id', 'customize_cf7_integration_list_id', 10, 3 );
    
    function customize_cf7_integration_list_id( $list_id, $data, $type ) {
    
    	// Make sure we're dealing with the CF7 integration
    	if ( $type !== 'contact_form_7' ) {
    		return $list_id;
    	}
    
    	// Get the current language from the URL
    
    	// English!
    	if ( isset( $_SERVER['REQUEST_URI'] ) && strpos( $_SERVER['REQUEST_URI'], '/en/' ) !== false ) {
    		return '9ef0149646'; // English List ID
    	}
    
    	// If we can't find any language specified, return the default list id.
    	return $list_id;
    }

    But it doesn’t work. What am I doing wrong?

    1. I selected only the Spanish list in the “parameters integration”
    2. I kept the previous function that you wrote (yikes_customize_cf7_checkbox_label)

    Thanks,
    Mireia

    • This reply was modified 5 years, 9 months ago by mirabela1982.
    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Hi Mireia,

    The snippet looks correct.

    What’s happening? When on the English site, is the subscription going to the Spanish list? Is it failing altogether?

    Let me know.

    Cheers,
    Kevin.

    Thread Starter mirabela1982

    (@mirabela1982)

    Exact. The English list is also going to Spanish list.

    Spanish list has to be the main one.

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Ah, I think I see the problem. We’re looking at the wrong URL to see if it’s English. Can you replace this snippet with this one:

    add_filter( 'yikes-mailchimp-checkbox-integration-list-id', 'customize_cf7_integration_list_id', 10, 3 );
    
    function customize_cf7_integration_list_id( $list_id, $data, $type ) {
    
    	// Make sure we're dealing with the CF7 integration
    	if ( $type !== 'contact_form_7' ) {
    		return $list_id;
    	}
    
    	// Get the current language from the URL
    
    	// English!
    	if ( isset( $_SERVER['HTTP_REFERER'] ) && strpos( $_SERVER['HTTP_REFERER'], '/en/' ) !== false ) {
    		return '9ef0149646'; // English List ID
    	}
    
    	// If we can't find any language specified, return the default list id.
    	return $list_id;
    }

    Let me know if you’d like me to test the form.

    All the best,
    Kevin.

    Thread Starter mirabela1982

    (@mirabela1982)

    Sorry, but not. Spanish version works perfectly. English version, I don’t receive the subscription email from Milchimp.

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Hi Mireia,

    Sorry about the delay – I was in a meeting.

    I just tested the form and didn’t receive the Mailchimp subscription email. Can you turn on debugging in our plugin? (Instructions: https://yikesplugins.com/support/knowledge-base/debug-settings/).

    Once debugging is on, can you try to subscribe again? (Or I can try too – just let me know).

    Thread Starter mirabela1982

    (@mirabela1982)

    I just activated the debugging mode.

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Can you check if anything was logged? I just filled out the form again.

    Thread Starter mirabela1982

    (@mirabela1982)

    mensaje de errores Detalles del error
    Invalid Resource Page: Checkbox Integrations || Type: Checkbox Integration Subscribe User || Time: 26 February, 2019 5:29 pm
    Invalid Resource Page: Checkbox Integrations || Type: Checkbox Integration Subscribe User || Time: 26 February, 2019 5:28 pm

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    So at least we know it’s failing. These issues can be a little tricky to work through. Do you have any required fields in your Mailchimp list?

Viewing 15 replies - 1 through 15 (of 29 total)
  • The topic ‘I see [yikes-mailchimp form=”1″] on the screen instead of the checkbox’ is closed to new replies.