I'm trying to create a custom call to the Campaign Monitor API when the user submits the form, and it's all working with one exception: the contact form never returns the success message to the browser, but rather hangs on "One moment please…"
This is not a path issue, as the Ajax is actually working correctly, it's just not returning the success message. I receive the email, and the Campaign Monitor call is also successful.
The code I'm using (in /plugins/cforms-custom/my-functions.php) is as follows:
function my_cforms_action($cformsdata) {
$form = $cformsdata['data'];
$subscribe = $form['I would like to subscribe to the Newsletter'];
if($subscribe == 'on') {
require_once('CMBase.php');
$api_key = 'MYACTUALAPIISHERE';
$client_id = 'MYACTUALAPIISHERE';
$campaign_id = null;
$list_id = 'MYACTUALAPIISHERE';
$cm = new CampaignMonitor( $api_key, $client_id, $campaign_id, $list_id );
//This is the actual call to the method, passing email address, name.
$result = $cm->subscriberAdd($form['Email'], $form['Your Name']);
}
}
The file "CMBase.php" is also in the cforms-custom directory, and I know it's being accessed correctly because the submission is working.
I've done a lot of troubleshooting and the line that seems to be giving the trouble is the require_once('CMBase.php'); line. Without that line the Ajax reply happens, with it, it doesn't.
I can't for the life of me figure out why that should be true.
Any help?