• Enis

    (@enistrevisi)


    I’m building a multilingual site using Polylang.

    I would like to allow my users to subscribe to a different MailChimp list according to the language the chose to see my website in when they submit a form made with ninja forms. Unfortunately, when I test it, the user gets subscribed to both lists.

    I added in my function.php the following code:

    add_filter( 'mc4wp_lists', 'myMc4wpI18n');
    add_filter( 'mc4wp_integration_lists', 'myMc4wpI18n');
    add_filter( 'mc4wp_integration_' . $slug . '_lists', 'myMc4wpI18n');
    
    function myMc4wpI18n ( $lists ) {
    
       $map = array(
          'en' => 'XXXXXXXXXXX',
          'it' => 'XXXXXXXXXXX'
       );
       $site_language = pll_current_language();
       if( isset( $map[ $site_language ] ) ) {
          $list_for_language = $map[ $site_language ];
          return array( $list_for_language );
       }
       // return default lists
       return $lists;
    }

    but it doesn’t work.

    Hacking the code, I found this $ninja_forms_processing global variable, but I don’t know how I could apply the same filter there.

    Any hint?

    https://wordpress.org/plugins/mailchimp-for-wp/

Viewing 1 replies (of 1 total)
  • Thread Starter Enis

    (@enistrevisi)

    Update: the problem appears only when I use ajax for submitting the form.

    If I post to a confirmation page, my custom code works.

    So I have to understand how the integration works on the ajax.

Viewing 1 replies (of 1 total)
  • The topic ‘Polylang multilingual site. Ninja forms subscribes user to two different lists’ is closed to new replies.