This guide will show you how to integrate Quform and the Mailster Newsletter plugin, by adding subscribers to a mailing list when the form is submitted. Add the following code to the WordPress theme functions.php file (or create a plugin for it).
Saving just an email address
12 345 6 7 8 9 10 11 | add_filter('quform_post_process_1', function (array $result, Quform_Form $form) { if (function_exists('mailster_subscribe')) { $email = $form->getValue('quform_1_3'); $lists = array('Default List'); $doubleOptIn = false; mailster_subscribe($email, array(), $lists, $doubleOptIn); } return $result; }, 10, 2); |
add_filter('quform_post_process_1', function (array $result, Quform_Form $form) { if (function_exists('mailster_subscribe')) { $email = $form->getValue('quform_1_3'); $lists = array('Default List'); $doubleOptIn = false; mailster_subscribe($email, array(), $lists, $doubleOptIn); } return $result; }, 10, 2);
1 2 3 456 7 8 9 10 11 12 13 | function my_quform_mailster_subscribe(array $result, Quform_Form $form) { if (function_exists('mailster_subscribe')) { $email = $form->getValue('quform_1_3'); $lists = array('Default List'); $doubleOptIn = false; mailster_subscribe($email, array(), $lists, $doubleOptIn); } return $result; } add_filter('quform_post_process_1', 'my_quform_mailster_subscribe', 10, 2); |
function my_quform_mailster_subscribe(array $result, Quform_Form $form) { if (function_exists('mailster_subscribe')) { $email = $form->getValue('quform_1_3'); $lists = array('Default List'); $doubleOptIn = false; mailster_subscribe($email, array(), $lists, $doubleOptIn); } return $result; } add_filter('quform_post_process_1', 'my_quform_mailster_subscribe', 10, 2);
Saving the first name, last name and email address
12 3456 7 8 9 10 11 12 13 14 15 16 | add_filter('quform_post_process_1', function (array $result, Quform_Form $form) { if (function_exists('mailster_subscribe')) { $email = $form->getValue('quform_1_3'); $name = $form->getValue('quform_1_4'); $lists = array('Default List'); $doubleOptIn = false; $data = array( 'firstname' => $name[2], 'lastname' => $name[4] ); mailster_subscribe($email, $data, $lists, $doubleOptIn); } return $result; }, 10, 2); |
add_filter('quform_post_process_1', function (array $result, Quform_Form $form) { if (function_exists('mailster_subscribe')) { $email = $form->getValue('quform_1_3'); $name = $form->getValue('quform_1_4'); $lists = array('Default List'); $doubleOptIn = false; $data = array( 'firstname' => $name[2], 'lastname' => $name[4] ); mailster_subscribe($email, $data, $lists, $doubleOptIn); } return $result; }, 10, 2);
1 2 3 4567 8 9 10 11 12 13 14 15 16 17 18 | function my_quform_mailster_subscribe(array $result, Quform_Form $form) { if (function_exists('mailster_subscribe')) { $email = $form->getValue('quform_1_3'); $name = $form->getValue('quform_1_4'); $lists = array('Default List'); $doubleOptIn = false; $data = array( 'firstname' => $name[2], 'lastname' => $name[4] ); mailster_subscribe($email, $data, $lists, $doubleOptIn); } return $result; } add_filter('quform_post_process_1', 'my_quform_mailster_subscribe', 10, 2); |
function my_quform_mailster_subscribe(array $result, Quform_Form $form) { if (function_exists('mailster_subscribe')) { $email = $form->getValue('quform_1_3'); $name = $form->getValue('quform_1_4'); $lists = array('Default List'); $doubleOptIn = false; $data = array( 'firstname' => $name[2], 'lastname' => $name[4] ); mailster_subscribe($email, $data, $lists, $doubleOptIn); } return $result; } add_filter('quform_post_process_1', 'my_quform_mailster_subscribe', 10, 2);