• Resolved jitske

    (@jitskepaladijncom)


    I would like to use the option to add customers to the right list, based on language.
    I found this documentation

    This is what I added to my funtions.php:

    <?php

    /**
    * Tell MailChimp for WordPress to subscribe to a certain list based on the WPML language that is being viewed.
    *
    * Make sure to change the list ID’s to the actual ID’s of your MailChimp lists
    *
    * @param array $lists
    * @return array $lists
    */
    add_filter( ‘mc4wp_lists’, function( $lists ) {

    $map = array(
    ‘nl’ => ‘Nederlands’,
    ‘fr’ => ‘Frans’,
    );

    $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;
    } );

    But than I get an error 500 when I try to use the website.
    My listnames are: Nederlands and Frans.

    So how can I make this work?

    Thanks for helping.

    https://www.ads-software.com/plugins/mailchimp-for-wp/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Lap

    (@lapzor)

    Error 500 means there is some error in the PHP code.

    Maybe try without the <?php as that would probably already be there on top of the file?

    Plugin Author Danny van Kooten

    (@dvankooten)

    Hi Jitske,

    Please be careful editing your functions.php like that as a missed character can mean potentially breaking your site.

    As Lap suggested, please make sure there is only one opening <?php tag. Also, the function expects your MailChimp list ID instead of the names. You can find the ID’s of your lists by checking the overview on the MailChimp for WP > MailChimp page.

    Hope that helps. If not, let me know!

    Thread Starter jitske

    (@jitskepaladijncom)

    Thanks guys! That help a lot

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WPML > 2 languages’ is closed to new replies.