Support » Plugin: MC4WP: Mailchimp for WordPress » Fallback Language for “Set list(s) based on site language”

  • Resolved antongr

    (@antongr)


    Hi there,
    first of all, thanks for building this handy plugin. It helps alot.

    I have one question regarding setting lists based on languages. Is there a fallback implemented in the code for undefined languages in the functions.php?

    Let’s say I have set 2 lists, one for “de” and one for “en”. Now I’d like to put all the people with browser language “es”, “fr” etc. also in my english mailchimp list. Is this possible or would I have to define all languages manually in the code ?

    Thanks for helping out here.

    All the best,
    Anton

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hey Anton,

    This would need to be done through code. Before I suggest anything, can you please share with us any code that you are already using?

    Hi Harish,

    the current code im using is this in functions.php:

    add_filter( 'mc4wp_lists', function( $lists ) {
       
       $map = array(
          'en' => '35682dce39',
          'de' => 'd2af493bde',
       );
       $site_language = defined( 'ICL_LANGUAGE_CODE' ) ? ICL_LANGUAGE_CODE : '';
       if( isset( $map[ $site_language ] ) ) {
          $list_for_language = $map[ $site_language ];
          return array( $list_for_language );
       }
       // return default lists
       return $lists;
    } );
    Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hey Anton,

    You could use the code at https://github.com/ibericode/mc4wp-snippets/blob/master/misc/set-list-based-on-wpml-language.php as a reference and then modify it to use an “if else” condition. You can then send users from certain languages to a specific list and any other languages to a default list.

    Plugin Contributor Lap

    (@lapzor)

    We have created a new add-on that you can use to set list based on WPML language without any custom code.

    For now you can download it here: https://github.com/ibericode/mc4wp-wpml

    It will soon be available for installation from the WordPress plugin repository.

    Hope that helps!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Fallback Language for “Set list(s) based on site language”’ is closed to new replies.