• Resolved ladydev

    (@ladydev)


    I am integrating HTML Forms with our MC4WP PRO plugin. The integration works as expected on our current form, however, I need to add multiple forms and subscriber tags. I am trying to add the tags based on the form id but nothing I’ve tried is working. I’ve looked around for examples but cannot find anything. What am I missing here?

    add_filter('mc4wp_integration_subscriber_data', function (MC4WP_MailChimp_Subscriber $subscriber, $hf_form) {
        if ($hf_form->form_id == 250328) {
            $subscriber->tags[] = 'Tag 1';
        } else if ($hf_form->form_id == 250329) {
            $subscriber->tags[] = 'Tag 2';
        }
        return $subscriber;
    }, 10, 2);
    • This topic was modified 1 year, 12 months ago by ladydev.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ladydev

    (@ladydev)

    I’ve also tried the following

    add_filter('mc4wp_integration_subscriber_data', function (MC4WP_MailChimp_Subscriber $subscriber, $form_id) {
        if ($form_id == 250328) {
            $subscriber->tags[] = 'Tag 1';
        } else if ($form_id == 250329) {
            $subscriber->tags[] = 'Tag 2';
        }
        return $subscriber;
    }, 10, 2);
    Thread Starter ladydev

    (@ladydev)

    Though this is not resolved, I am marking as such because I think this question belongs on the MC4WP support forum rather than here.

    Hi,

    I assume you’re using the custom integration method?
    The form ID won’t be available via an action argument, but it will be available via $_POST[‘_hf_form_id’]

    add_filter( 'mc4wp_integration_woocommerce_subscriber_data', function( MC4WP_MailChimp_Subscriber $subscriber ) {
    
    if (isset($_POST['_hf_form_id']) && $_POST['_hf_form_id'] == 250328) {
            $subscriber->tags[] = 'Tag 1';
        } else if (isset($_POST['_hf_form_id']) && $_POST['_hf_form_id'] == 250329) {
            $subscriber->tags[] = 'Tag 2';
    }
    
        return $subscriber;
    });

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to add MailChimp subscriber tags?’ is closed to new replies.