Created
April 9, 2025 03:06
-
-
Save xnau/6c81320e8a2970fec28fd8b1abf0babb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: PDb MailChimp Custom Merge Tags | |
* Description: adds a custom merge tag to the MailChimp registration | |
* Author: Roland Barker, xnau webdesign | |
* Version: 1.0 | |
* Author URI: https://xnau.com | |
* License: GPL3 | |
*/ | |
class PDb_MailChimp_Custom { | |
/** | |
* sets up the filters | |
*/ | |
public function __construct() | |
{ | |
// this filter gives you access to the data before it is sent to MailChimp | |
add_filter( 'pdbmc-data_before_send', [$this,'add_merge_tag'] ); | |
} | |
/** | |
* adds the merge tag to the MailChimp registration data | |
* | |
* @param array $mc_data | |
* @return array | |
*/ | |
public function add_merge_tag( $mc_data ) | |
{ | |
// the "full_address" field is not a real database field, just a name for the extra data we're adding | |
// "full_address" is the local name for the field, "M_ADDRESS" is the MC merge tag name for the field | |
$mc_data['full_address'] = $mc_data['address'] . ' ' . $mc_data['city'] . ' ' . $mc_data['state'] . ' ' . $mc_data['zip']; | |
return $mc_data; | |
} | |
} | |
new PDb_MailChimp_Custom(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You must configure the merge tag you are going to use for your custom tag, both in the Participants Database MailChimp Integration plugin and in your MailChimp account audience settings.
You can ignore the warning about the field not being a Participants Database field if you see it.