Hi John -
I did get it figured out, so that when an event happened at s2member (registration) it would notify Mautic and add the subscriber to a segment. I haven’t used either platform (s2member or Mautic) in some time so some of this is from memory.
The first thing I did was add a php file called mautic-notify.php to a sub directory in my website structure (e.g. public_html/mautic-notify/mautic-notify.php). I added an index.html file in that directory too, so that random people couldn’t happen on by and see the php file. The contents of the PHP file which I got from this site are down below.
I then went to my s2member settings and under API/Notifications and under registration I built the url TO the php file putting the series of whatever Mautic field names and the corresponding s2member variables you want - like this &fieldname=%%variable%%&fieldname=%%variable%% etc etc. into the URL you are building.
So it looked something like this:
https
// exampleweb.com/mautic-notify/mautic-notify.php?keyID=blahblahcode&fname=%%user_first_name&lname=%%user_last_name%%&email=%%user_email%%
Make sure for each field name and variable set you add also has an entry under //load up the data in the file parts that look like this:
$data[ ‘first_name’ ] = $_GET[‘fname’];
You’ll also notice the keyID. That is the first variable used so that the php file won’t be called into action at random without knowing that key. So the keyID in the php file and in the URL call have to match. You may want to change that every so often…just because.
Below is the contents of my php file. I made sure that the keyID matched up - both in the file and in the url, then also made sure my Mautic url replaced [YourMauticURL.com], then made sure the formID matched the form ID in Mautic.
It may take a couple tries, but that’s what I did to get it to work. Good Luck!
<?php
if ($_GET['keyID'] === 'blahblahcode'){
// load up the data
$data[ 'first_name' ] = $_GET['fname'];
$data[ 'last_name' ] = $_GET['lname'];
$data[ 'email' ] = $_GET['email'];
//Get IP
$ip = $_GET["ip"];
//set Mautic form ID
$formId = '2';
$data[ 'formId' ] = $formId;
// return has to be part of the form data array
$data[ 'return' ] = 'http://where-to-redirect.com';
// set the payload
// NOTE: It's confusing using 2 different $data vars... but $data is a new thing now
$data = array ( 'mauticform' => $data );
// Change [path-to-mautic] to URL where your Mautic is
$formUrl = 'https://[YourMauticURL.com]/form/submit?formId=' . $formId;
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $formUrl );
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query( $data ) );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array ( "X-Forwarded-For: $ip" ) );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$response = curl_exec( $ch );
curl_close( $ch );
//return $response;
}
exit;
?>