Home › Forums › Quform WordPress › MailChimp functions.php
- This topic has 1 reply, 2 voices, and was last updated 11 years, 8 months ago by Ally.
- AuthorPosts
- March 23, 2013 at 1:45 am #3527horsemaidsissiParticipant
Hi,
I have been working on linking my form with Mailchimp. I got through all your instructions fine, and added the code into functions.php. When I load my site I now see all the code I just added at the very top of the page.
What am I doing wrong? PS. I included the last few lines of code just in case I missed something. I’ve been imputing from add_action.
?php endforeach; ?>
<?php
// Reset the global $the_post as this query will have stomped on it
wp_reset_postdata();
endif;
?>
<input type="hidden" id="<?php echo $widgetId; ?>_offset" name="<?php echo $widgetId; ?>_offset" value="<?php echo $offset; ?>"/>
<?php
}
?>add_action('iphorm_post_process_1', 'mytheme_save_to_mailchimp', 10, 1);
function mytheme_save_to_mailchimp($form)
{
require_once dirname(__FILE__) . '/MCAPI.class.php';$api = new MCAPI('myactualapikey'); $listId = 'myactuallistid'; $email = $form->getValue('iphorm_1_3');
// OPTIONAL: if you are saving additional fields to MC, set the merge tags, otherwise set $mergeVars to an empty array
$mergeVars = array(
'EMAIL' => $form->getValue('iphorm_1_3'),
'FNAME' => $form->getValue('iphorm_1_1'),
'LNAME' => $form->getValue('iphorm_1_6'),
'COMPANY' => $form->getValue('iphorm_1_2'),
'WSITE' => $form->getValue('iphorm_1_20'),
'PHONE' => $form->getValue('iphorm_1_30'),
'JOBDESC' => $form->getValue('iphorm_1_19'),
'ADDRESS' => $form->getValue('iphorm_1_9'),
'ADDRESSD' => $form->getValue('iphorm_1_15'),
'CITY' => $form->getValue('iphorm_1_16'),
'PCODE' => $form->getValue('iphorm_1_12'),
'PROVINCE' => $form->getValue('iphorm_1_11'),
'URGENCY' => $form->getValue('iphorm_1_24'));
// Other settings
$emailType = 'html';
$doubleOptin = false;
$updateExisting = false;
$replaceInterests = false;
$sendWelcome = false;$api->listSubscribe($listId, $email, $mergeVars, $emailType, $doubleOptin, $updateExisting, $replaceInterests, $sendWelcome);
}Thanks for your help!
ChelseyMarch 24, 2013 at 1:41 pm #3534AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- AuthorPosts
- You must be logged in to reply to this topic.