This guide will show you how to add a new contact to Mailrelay when a user submits a Quform form.

Add the following code to the WordPress theme functions.php file (or create a plugin for it).

1234
5
6
7
891011
12
13
14
15
16
17
18
add_filter('quform_post_process_1', function (array $result, Quform_Form $form) {    $apiUrl = 'https://example.com/ccm/admin/api/version/2/&type=json';    $apiKey = 'yourApiKey'; 
    $data = array(
        'function' => 'addSubscriber',
        'apiKey' => $apiKey,
        'email' => $form->getValueText('quform_1_4'),        'name' => $form->getValueText('quform_1_3'),        'groups' => array(10, 14),    );
 
    wp_remote_post($apiUrl, array(
        'body' => $data
    ));
 
    return $result;
}, 10, 2);
add_filter('quform_post_process_1', function (array $result, Quform_Form $form) {
    $apiUrl = 'https://example.com/ccm/admin/api/version/2/&type=json';
    $apiKey = 'yourApiKey';

    $data = array(
        'function' => 'addSubscriber',
        'apiKey' => $apiKey,
        'email' => $form->getValueText('quform_1_4'),
        'name' => $form->getValueText('quform_1_3'),
        'groups' => array(10, 14),
    );

    wp_remote_post($apiUrl, array(
        'body' => $data
    ));

    return $result;
}, 10, 2);
  • On line 1, replace the number 1 with the form ID
  • On line 2, replace https://example.com/ccm/admin/api/version/2/&type=json with your Mailrelay API URL
  • On line 3, replace yourApiKey your Mailrelay API Key
  • On line 8, replace 1_4 with the Email element unique ID
  • On lines 9, replace 1_3 with the Name element unique ID if the form has a Name element, otherwise this line can be removed
  • On line 10, replace 10, 14 with the comma separarated list of Mailrelay group IDs to add the subscribers to

See also

Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy