# Send the Visitor's Language to Mailchimp (MC4WP)

> Sets Mailchimp's built-in subscriber language for every signup from your site, using the current WordPress, WPML or Polylang language, so Mailchimp can send the right translation of your campaigns.

- Type: PHP
- Runs: Run everywhere
- Category: [Plugin Integrations](https://wpide.com/library/category/integrations/)
- Tags: mailchimp, multilingual, newsletter
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/mc4wp-sync-language-merge-field/

## Code

```php
add_filter( 'mc4wp_subscriber_data', function ( $subscriber ) {
    if ( ! is_object( $subscriber ) ) {
        return $subscriber;
    }

    $lang = strtok( determine_locale(), '_' );
    if ( function_exists( 'pll_current_language' ) && pll_current_language() ) {
        $lang = pll_current_language();
    } elseif ( defined( 'ICL_LANGUAGE_CODE' ) && ICL_LANGUAGE_CODE ) {
        $lang = ICL_LANGUAGE_CODE;
    }

    $subscriber->language = strtolower( substr( sanitize_key( $lang ), 0, 2 ) );

    return $subscriber;
} );
```

## Notes

Mailchimp expects codes like en, fr, de or pt_PT; regional variants are mapped to the two-letter code.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Send the Visitor's Language to Mailchimp (MC4WP)" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
