This documentation page is for Quform version 1 and may not be applicable for Quform 2 click here to visit the documentation for Quform 2.

Step 1

Download the Aweber PHP API from https://github.com/aweber/AWeber-API-PHP-Library. Click the github-zip button to download.

Step 2

Extract the .zip file and there will be a folder named aweber_api, move this to your theme directory so that it resides at: wp-content/themes/YOUR_THEME/aweber_api/

Step 3

Get your Aweber API credentials and other information, consult the Aweber help for how to find this information. You will need:

  • Consumer key – set the $consumerKey variable in the code below to this
  • Consumer secret – set the $consumerSecret variable in the code below to this
  • Access key – set the $accessKey variable in the code below to this
  • Access secret – set the $accessSecret variable in the code below to this
  • Account ID – set the $account_id variable in the code below to this
  • List ID – set the $list_id variable in the code below to this
  • The names of any custom fields from your list that you want to save data to (optional)

Step 4

Add the following code to the wp-content/themes/YOUR_THEME/functions.php file (or create a plugin for it).

12
3
4
5
6
78910111213
14
15
16
17
18
19
20
21
22
2324
2526
272829
30
31
32
33
34
35
36
37
38
add_action('iphorm_post_process_3', 'my_save_to_aweber', 10, 1); 
function my_save_to_aweber($form)
{
    require_once('aweber_api/aweber_api.php');
 
    $consumerKey    = '***'; # put your credentials here    $consumerSecret = '***'; # put your credentials here    $accessKey      = '***'; # put your credentials here    $accessSecret   = '***'; # put your credentials here    $account_id     = '***'; # put the Account id here    $list_id        = '***'; # put the List id here 
    $aweber = new AWeberAPI($consumerKey, $consumerSecret);
 
    try {
        $account = $aweber->getAccount($accessKey, $accessSecret);
        $lists = $account->lists->find(array('name' => $list_id));
        $list = $lists[0];
 
        # create a subscriber
        $params = array(
            'email' => $form->getValue('iphorm_3_2'),            'ip_address' => $_SERVER['REMOTE_ADDR'],
            'name' => $form->getValue('iphorm_3_3'),            'custom_fields' => array(
                'Custom field 1' => $form->getValue('iphorm_3_4'),                'Custom field 2' => $form->getValue('iphorm_3_5'),            )
        );
        $subscribers = $list->subscribers;
        $new_subscriber = $subscribers->create($params);
    } catch(AWeberAPIException $exc) {
        if (WP_DEBUG) {
            throw $exc;
        }
    }
}
add_action('iphorm_post_process_3', 'my_save_to_aweber', 10, 1);

function my_save_to_aweber($form)
{
    require_once('aweber_api/aweber_api.php');

    $consumerKey    = '***'; # put your credentials here
    $consumerSecret = '***'; # put your credentials here
    $accessKey      = '***'; # put your credentials here
    $accessSecret   = '***'; # put your credentials here
    $account_id     = '***'; # put the Account id here
    $list_id        = '***'; # put the List id here

    $aweber = new AWeberAPI($consumerKey, $consumerSecret);

    try {
        $account = $aweber->getAccount($accessKey, $accessSecret);
        $lists = $account->lists->find(array('name' => $list_id));
        $list = $lists[0];

        # create a subscriber
        $params = array(
            'email' => $form->getValue('iphorm_3_2'),
            'ip_address' => $_SERVER['REMOTE_ADDR'],
            'name' => $form->getValue('iphorm_3_3'),
            'custom_fields' => array(
                'Custom field 1' => $form->getValue('iphorm_3_4'),
                'Custom field 2' => $form->getValue('iphorm_3_5'),
            )
        );
        $subscribers = $list->subscribers;
        $new_subscriber = $subscribers->create($params);
    } catch(AWeberAPIException $exc) {
        if (WP_DEBUG) {
            throw $exc;
        }
    }
}

Modify the highlighted lines to suit your setup:

  • On line 1, change the number 3 to the unique ID of your form, see Finding the form ID.
  • On lines 7-12, change all the *** to each of your Aweber settings described in Step 3.
  • On line 23, change iphorm_3_2 to the unique ID of the email element in your form, from Step 5.
  • On line 25, change iphorm_3_3 to the unique ID of the name element in your form, from Step 5. If you don’t have a name element you should delete the line.
  • On line 27, change Custom field 1 to the name of your first Custom field at Aweber. Repeat this on the lines below for each custom field, adding more lines if required. If you don’t want to save any custom fields, delete lines 26-29 from the code.
  • On line 27, change iphorm_3_4 to the unique Quform element ID of the field you want to save into ‘Custom field 1’ (or whatever the name of your custom field). Repeat for your other custom fields.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy