Home › Forums › Quform WordPress › Use of plugin for mailchimp code
This topic is: resolved
- This topic has 2 replies, 2 voices, and was last updated 8 years, 2 months ago by fulmin.
Viewing 3 posts - 1 through 3 (of 3 total)
- AuthorPosts
- February 1, 2016 at 10:09 pm #18079fulminParticipant
Hello,
I ve follow the instructions to create a plugin for my mailchimp code but it doesnt work. When the form is send, I got an error in my browser. (The code works fine if put directly in function.php.)
Could you have a look and tell me if something is wrong please ?
Thx a lot
<?php /* * Plugin Name: Quform Custom Code * Description: Custom code for Quform. * Version: 1.0 */ // Paste in your custom code below function my_save_to_mailchimp($form) { if (!class_exists('MCAPI')) { require_once dirname(__FILE__) . '/MCAPI.class.php'; } $api = new MCAPI('xxxxxxxxxxxxx'); $listId = 'xxxxxxxx'; switch($form->getId()) { case 24: $email = $form->getValue('iphorm_24_2'); $fname = $form->getValue('iphorm_24_1'); break; case 13: $email = $form->getValue('iphorm_13_2'); $fname = $form->getValue('iphorm_13_1'); $news= $form->getValue('iphorm_13_11'); break; case 14: $email = $form->getValue('iphorm_14_2'); $fname = $form->getValue('iphorm_14_1'); $news= $form->getValue('iphorm_14_11'); break; case 20: $email = $form->getValue('iphorm_20_2'); $fname = $form->getValue('iphorm_20_1'); $news= $form->getValue('iphorm_20_11'); break; case 25: $email = $form->getValue('iphorm_25_2'); $fname = $form->getValue('iphorm_25_1'); $news= $form->getValue('iphorm_25_14'); break; case 16: $email = $form->getValue('iphorm_16_2'); $fname = $form->getValue('iphorm_16_1'); $news= $form->getValue('iphorm_16_11'); break; case 35: $email = $form->getValue('iphorm_35_2'); $fname = $form->getValue('iphorm_35_1'); $news= $form->getValue('iphorm_35_33'); break; case 8: $email = $form->getValue('iphorm_8_2'); $fname = $form->getValue('iphorm_8_1'); $news= $form->getValue('iphorm_8_12'); break; case 19: $email = $form->getValue('iphorm_19_2'); $fname = $form->getValue('iphorm_19_1'); $news= $form->getValue('iphorm_19_11'); break; case 31: $email = $form->getValue('iphorm_31_2'); $fname = $form->getValue('iphorm_31_1'); $news= $form->getValue('iphorm_31_11'); break; } // OPTIONAL: if you are saving additional fields to MC, set the merge tags, otherwise set $mergeVars to an empty array $mergeVars = array( 'MERGE1' => $fname, 'NEWS' => $news, ); // Other settings $emailType = 'html'; $doubleOptin = false; $updateExisting = false; $replaceInterests = false; $sendWelcome = false; $api->listSubscribe($listId, $email, $mergeVars, $emailType, $doubleOptin, $updateExisting, $replaceInterests, $sendWelcome); } add_action('iphorm_post_process_24', 'my_save_to_mailchimp', 10, 1); add_action('iphorm_post_process_13', 'my_save_to_mailchimp', 10, 1); add_action('iphorm_post_process_14', 'my_save_to_mailchimp', 10, 1); add_action('iphorm_post_process_20', 'my_save_to_mailchimp', 10, 1); add_action('iphorm_post_process_25', 'my_save_to_mailchimp', 10, 1); add_action('iphorm_post_process_16', 'my_save_to_mailchimp', 10, 1); add_action('iphorm_post_process_35', 'my_save_to_mailchimp', 10, 1); add_action('iphorm_post_process_8', 'my_save_to_mailchimp', 10, 1); add_action('iphorm_post_process_19', 'my_save_to_mailchimp', 10, 1); add_action('iphorm_post_process_31', 'my_save_to_mailchimp', 10, 1); ?>
- This topic was modified 8 years, 2 months ago by fulmin.
February 3, 2016 at 10:52 am #18085AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
February 6, 2016 at 5:37 pm #18133fulminParticipantThx Ally, it was that !
- AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.