Using Gravity Forms ‘gform_icontact_request_args’ PHP filter

The gform_icontact_request_args filter allows you to modify the options array before sending requests to iContact.

Usage

add_filter('gform_icontact_request_args', 'my_custom_function', 10, 4);

Parameters

  • $options (array): Query arguments to be sent in the request.
  • $action (string): The action being sent to the iContact API, passed in the URL.
  • $method (string): The request method being used, e.g., GET.
  • $return_key (string): The array key desired from the response.

More information

See Gravity Forms Docs: gform_icontact_request_args

Examples

Modify request options

Modify the request options before sending to iContact.

function modify_icontact_request_args($options, $action, $method, $return_key) {
    // Your custom code here
    return $options;
}
add_filter('gform_icontact_request_args', 'modify_icontact_request_args', 10, 4);

Add custom header

Add a custom header to the iContact API request.

function add_custom_header($options, $action, $method, $return_key) {
    $options['headers']['X-Custom-Header'] = 'YourCustomValue';
    return $options;
}
add_filter('gform_icontact_request_args', 'add_custom_header', 10, 4);

Change request method

Change the request method for a specific action.

function change_request_method($options, $action, $method, $return_key) {
    if ($action == 'specific_action') {
        $method = 'POST';
    }
    return $options;
}
add_filter('gform_icontact_request_args', 'change_request_method', 10, 4);

Modify request options based on action

Modify request options based on the action being sent to iContact.

function modify_request_based_on_action($options, $action, $method, $return_key) {
    if ($action == 'example_action') {
        // Your custom code here
    }
    return $options;
}
add_filter('gform_icontact_request_args', 'modify_request_based_on_action', 10, 4);

Remove specific request option

Remove a specific request option before sending the request to iContact.

function remove_specific_option($options, $action, $method, $return_key) {
    unset($options['example_key']);
    return $options;
}
add_filter('gform_icontact_request_args', 'remove_specific_option', 10, 4);