Home / Archive / MemberPress: Kit (formerly ConvertKit) – Remove Kit Inactive Tag for Inactive Subscribers
Duplicate Snippet

Embed Snippet on Your Site

MemberPress: Kit (formerly ConvertKit) – Remove Kit Inactive Tag for Inactive Subscribers

By default, MemberPress integration with Kit will add the “inactive” tag when a user becomes inactive in MemberPress. At the same time, it will remove the “active” tag,

Adding this code snippet to the website will modify the default behavior and remove both “active” and "inactive" tags from a subscriber in Kit when the subscriber becomes inactive in MemberPress.

Code Preview
php
<?php
// Remove the inactive tag
function mepr_remove_ck_inactive_tag_from_subscriber($txn) {
    $contact          = $txn->user();
    $enabled          = (bool)get_post_meta($txn->product_id, '_meprconvertkit_tag_override', true);
    $active_tag_id    = get_post_meta($txn->product_id, '_meprconvertkit_tag_override_id', true);
    $inactive_tag_id  = get_post_meta($txn->product_id, '_meprconvertkit_inactive_tag_override_id', true);
    
    $ck = new MpConvertKit();
    // Remove active tag
    if ($enabled && !empty($active_tag_id)) {
        $ck->remove_tag_from_subscriber($contact, $active_tag_id);
    }
    // Updated: Remove inactive tag instead of adding it
    if ($enabled && !empty($inactive_tag_id)) {
        $ck->remove_tag_from_subscriber($contact, $inactive_tag_id);
    }
    return false;
}
add_action('mepr-account-is-inactive', 'mepr_remove_ck_inactive_tag_from_subscriber', 9999);

Comments

Add a Comment