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

    (@lapzor)

    Here is a code snippet example for setting a tag per form:
    https://github.com/ibericode/mc4wp-snippets/blob/master/integrations/ninja-forms/different-tag-per-form.php

    This can also be adapted to support interest groups instead of tags by using

    $subscriber->interests[ “interest-id” ] = true;

    instead of $subscriber->tags[] = ‘NL’;

    Hope that helps. If you have any questions, please let me know!

    Thread Starter Simone Montanari

    (@semikola)

    Hi there,

    thank you for your quick reply. I tried the solution in the code snippet but I come across a problem.

    My interest field looks like this in the form:

    <input type="hidden" name="INTERESTS[761fe95add]" value="Summer project">

    And the snippet like this:

    add_filter( 'mc4wp_integration_ninja-forms_subscriber_data', function(MC4WP_MailChimp_Subscriber $subscriber, $form_id) {
        if ($form_id == 3) {
            $subscriber->interests['761fe95add'] = true;
        } 
        return $subscriber;
    }, 10, 2);

    When I tried to subscribe from the form I receive this error:

    [2021-06-09 15:37:39] ERROR: Ninja Forms > Mailchimp API Error: Bad Request. Invalid Resource. Invalid interest ID: '761fe95add'.
    Request:
    POST https://us6.api.mailchimp.com/3.0/lists/**********/members
    {"status":"pending","email_address":"name.***+TEST@gm***.com","interests":{"761fe95add":true},"merge_fields":{"MMERGE1":"Name"},"email_type":"html","ip_signup":"95.90.***.***","tags":[]}
    Response:
    400 Bad Request
    {"type":"https://mailchimp.com/developer/marketing/docs/errors/","title":"Invalid Resource","status":400,"detail":"Invalid interest ID: '761fe95add'.","instance":"722e0f6f-31b0-****-94cd-************"}

    Am I using the wrong ID? Where should I get the correct one?

    Thanks a lot for your help,

    Simone

    Plugin Contributor Lap

    (@lapzor)

    Please go to Mailchimp for WP > Mailchip and click on your audience name, that’s where you see the interest group ID.

    Thread Starter Simone Montanari

    (@semikola)

    Hi Lap,

    that worked, thanks a lot!

    Have a nice,

    Simone

    I am interesting in using this with Ninja Forms but instead of using an hidden field I would like the user to check the options in the Checkbox List.

    What would be the correct way of doing this?

    Thanks for your help.

    Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hey @yepecece,

    Please note that this topic is marked as resolved. Please create a new one with your question.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Add Mailchimp interest choice to Ninja Forms’ is closed to new replies.