Hi Matt,
thanks for reaching out. I was also confused in the beginning on how this works with Mailchimp. In their terminology, a “campaign” if a single sent “newsletter email”. Those can be grouped in “campaign folder”. In the single campaign you will find a “folder_id” which you could use to filter the campaigns.
I’ve added a filter to make this possible, but I just realized that I used the wrong name there. Before you use it, please give me some time tomorrow to fix the name.
Filtering campaigns by folder and by date is something I wanted to add to a future version of the plugin, but for the first release this was a bit too complex.
For your use-case, would it help you to have a filter to alter the campaign before they go into the foreach loop?
Hi Matt,
I’ve just released a new version. You can now use the filter cabfm_campaigns_query_args
to add arguments to the Mailchimp API call and cabfm_campaigns_markup
to modify the rendered markup.
You could use the “folder_id” field to filter for the “campaign folder”: https://mailchimp.com/developer/marketing/api/campaigns/list-campaigns/
Thank you for being so willing to make some changes Bernhard 🙂 I haven’t had a chance to test this out yet, but will do later this week and will report back.
Hi Bernhard
I’ve tested this now and it works with the filter, many thanks!
One thing though: Mailchimp don’t make it wasy to get the folder ID. There is an “f_folder” in the URL when you navigate to the folder, but that’s not it. I had to make a GET request to the /campaign-folders endpoint to list them all, and the response shows that the folder_id needed is in the format “ab7abba2f8”. Once I’d added a filter to add that to the $query_args, it worked as expected. So one enhancement, should you be inclined, would be to make that campaign-folders request in the Settings and offer a list of Campaign folders to display.
Thanks again 🙂
Matt
Hi Matt,
that’s exactly the feature I’m currently working at. I already finished the part getting the folder names and IDs from the Mailchimp API. Now I “only” have to implement the block setting with a dropdown to select those folders. But this is still the hard part for me as I still haven’t completely learned how to load dynamic data into blocks/React. I have the custom REST endpoint bug still need some lines of JS code to make them work 🙂