Gigio Mailshot
Send a MailChimp email summarising upcoming events (WordPress plugin)
by Alan Cameron Wills · github.com/alancameronwills/gigio-mailshot
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/alancameronwills/gigio-mailshot/archive/refs/heads/main.zipGigio Mailshot - WordPress plugin
Creates a summary on MailChimp of events published on your website.
Built for https://moylgrove.wales
Website prerequisites
Assumptions about your WordPress site:
- The gigiau-events-posters plugin is installed and active. Events are read from its
gigcategory posts using its owngigio_get_gigs_with_recurs/gigio_get_gigsfunctions, so recurrence, expiry (dtend) and approval-gating are all handled there.venueis shown as the event subtitle anddtinfoas the price/extra-info line.
Assumptions about your MailChimp account:
- You've set up a separate folder for the emails generated by this plugin
Keys
Requires a file 'MailChimpKeys.php' (not on GitHub) that contains MailChimp keys:
<?php
class MailChimpKeys {
protected const MailChimpKey = "XXXXX"; // API key provided by MailChimp
protected const MailChimpAuthorization = "Basic YYYYY"; //Authorization: base64 rendition of x:{MailChimpKey}
protected const MailChimpUrl = "https://ZZZZ.api.mailchimp.com/3.0/";
protected const FolderID = "MMMMM"; // MailChimp campaign folder for these generated emails
}
Easiest way of getting MailChimpAuthorization is to use curl:
curl --headers https://ZZZZ.api.mailchimp.com/3.0/ping --user x:XXXXX
where 'x' can be anything, including just 'x', and XXXXX is the MailChimpKey.
Look at the request header that curl sends, and copy the Authorization header.
Usage
Set up a page that won't be visible to the public - e.g. a post with "Uncategorized" category or Draft status.
Include in it a shortcode:
[gigio-mailshot]
View the page and you'll see a version of the email that will be generated.
Refresh the page with a query appended to the URL:
?test=1- Will send a test email?send=1- Sends to the default audience of the MailChimp account. Also deletes all previous mails in the folder.?ping=1- Tests the connection to MailChimp