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);
  • On line 1, replace the number 1 with the form ID
  • On line 3, replace 1_3 with the Email element unique ID
  • On line 4, replace Default List with the name of the Mailster list to add the subscriber to
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);
  • On line 4, replace 1_3 with the Email element unique ID
  • On line 5, replace Default List with the name of the Mailster list to add the subscriber to
  • On line 13, replace the number 1 with the form ID

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);
  • On line 1, replace the number 1 with the form ID
  • On line 3, replace 1_3 with the Email element unique ID
  • On line 4, replace 1_4 with the Name element unique ID
  • On line 5, replace Default List with the name of the Mailster list to add the subscriber to
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);
  • On line 4, replace 1_3 with the Email element unique ID
  • On line 5, replace 1_4 with the Name element unique ID
  • On line 6, replace Default List with the name of the Mailster list to add the subscriber to
  • On line 18, replace the number 1 with the form ID
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy