• I wanted a mechanism to select which Mailchimp campaigns to render on my WP site. Indeed, by default the plugin automatically publishes all campaigns when importing, and does not allow to filter out campaigns to import and publish; consequently, every subsequent import would re-import / re-publish all campaigns.

    I fixed this by modifying 3 lines of code:
    – in /mailchimp-campaigns-manager.php: changed line 24 by define('MCC_DEFAULT_CPT_STATUS', 'draft');
    so that campaigns get created as Draft when imported using the plugin admin feature. (hence, no ‘auto-publish of imported campaigns)
    – in class/MailChimpCampaign.php: added in line 45
    'post_status' => array('publish','draft','trash'),
    so that the plugin would search amongst draft and trashed campaign as well when trying to determine if a campaign was already imported
    – in class/MailChimpCampaign.php: added in line 166
    if ($this->post_exists) unset($this->post->post_status);
    to preserve the status of existing campaigns.

    This way, when Iimport campaigns, all newly imported campaigns are created as draft, whereas existing campaigns have their status preserved, which allows me to either leave those that I don’t want to publish on my site as draft (or put in the trash bin).

    This is a quick hack that perhaps Matthieu will like to use to improve his plugin ?…

  • The topic ‘Dealing with repeating imports’ is closed to new replies.