Hooks and Filters
Advanced Form Integration exposes a set of WordPress actions and filters for customising behaviour without editing the plugin. Add the snippets below to your child theme’s functions.php or to a small site-specific plugin.
Everything on this page is stable public API. Internal functions not listed here can change between releases.
Registering platforms
adfoin_form_providers
Filters the list of form plugins AFI can trigger from. Use it to register a form plugin AFI does not support out of the box.
add_filter( 'adfoin_form_providers', function ( $providers ) {
$providers['myforms'] = 'My Forms Plugin';
return $providers;
} );
adfoin_action_providers
Filters the list of destination platforms, grouped by category. Use it to register a custom receiver.
add_filter( 'adfoin_action_providers', function ( $actions ) {
$actions['mycrm'] = array(
'title' => 'My CRM',
'tasks' => array( 'subscribe' => 'Create Contact' ),
);
return $actions;
} );
adfoin_settings_tabs
Adds a tab to AFI → Settings so your platform can collect its own credentials.
add_filter( 'adfoin_settings_tabs', function ( $tabs ) {
$tabs['mycrm'] = 'My CRM';
return $tabs;
} );
adfoin_platform_scripts
Filters the map of platform slugs to their front-end component scripts. AFI scans the platforms/ directory automatically, so this is only needed when a platform lives outside that structure.
Controlling when integrations run
adfoin_should_queue
Decides whether a specific submission runs through Action Scheduler in the background or fires immediately in the request. The default is your global Job Queue setting.
// Never queue anything from form 42, so it fires synchronously.
add_filter( 'adfoin_should_queue', function ( $should_queue, $record, $posted_data ) {
if ( isset( $record['form_id'] ) && '42' === (string) $record['form_id'] ) {
return false;
}
return $should_queue;
}, 10, 3 );
Parameters are bool $should_queue, array $record (the integration record), and array $posted_data (the submission payload).
Synchronous execution makes the visitor wait for the remote API, so use it sparingly. It is mainly useful when a downstream step needs the result immediately.
adfoin_parse_shortcodes
Controls whether shortcodes inside mapped values are executed before sending. Defaults to true.
// Turn shortcode parsing off everywhere.
add_filter( 'adfoin_parse_shortcodes', '__return_false' );
Parameters are bool $run_shortcodes, mixed $field (the field being parsed), and array $posted_data.
Switching this off is worth considering if your forms accept free text from the public, since it stops a submitted [shortcode] string from being executed on your server.
Special tags
adfoin_special_tags
Filters the tag list shown in the field-mapping dropdown. Use it to register tags of your own.
add_filter( 'adfoin_special_tags', function ( $tags, $cat ) {
if ( 'utm' === $cat ) {
return $tags; // leave the UTM group alone
}
$tags['_membership_level'] = '_Membership_Level';
return $tags;
}, 10, 2 );
Parameters are array $result (a map of tag key to display label) and string $cat, which is 'utm', 'st', or an empty string for the combined list.
adfoin_special_tag_value
Supplies the value for a tag at send time. This is where a tag registered above gets filled in, and it can also override a built-in tag.
add_filter( 'adfoin_special_tag_value', function ( $value, $tag, $current_user, $post ) {
if ( '_membership_level' === $tag && $current_user ) {
return get_user_meta( $current_user->ID, 'membership_level', true );
}
return $value;
}, 10, 4 );
Parameters are mixed $value, string $tag, WP_User|null $current_user, and WP_Post|null $post. Unknown tags arrive with an empty string, so returning $value unchanged is always safe.
See UTM Parameters and Special Tags for the full list of built-in tags.
Credentials
adfoin_get_credentials
Filters the credential set resolved for a platform before a request goes out. Useful for pulling secrets from an environment variable or a vault rather than the database.
add_filter( 'adfoin_get_credentials', function ( $credentials, $platform ) {
if ( 'mycrm' === $platform ) {
$credentials['api_key'] = getenv( 'MYCRM_API_KEY' );
}
return $credentials;
}, 10, 2 );
Parameters are array $credentials and string $platform.
Logging
adfoin_log_request_args
Filters the outgoing request arguments as they are recorded in the log. Use it to redact secrets before they are written to the database.
add_filter( 'adfoin_log_request_args', function ( $args, $url, $record ) {
if ( isset( $args['headers']['Authorization'] ) ) {
$args['headers']['Authorization'] = '[redacted]';
}
return $args;
}, 10, 3 );
Parameters are array $args, string $url, and array $record.
adfoin_log_response_body
Filters the response body before it is stored. Handy for truncating very large payloads or stripping personal data.
Parameters are mixed $response_body, array $record, and string $url.
Error emails
When a request fails, AFI can email the site administrator. Four hooks shape that email.
adfoin_send_api_error_email
An action that fires on every API failure, before the email is composed. Use it to route failures somewhere other than email, such as Slack or an error tracker.
add_action( 'adfoin_send_api_error_email', function ( $return, $record, $request_data, $context ) {
error_log( 'AFI failure in ' . $context );
}, 10, 4 );
Parameters are mixed $return (a WP_Error or the response array), array $record, array $request_data, and string $context.
adfoin_error_email_to, adfoin_error_email_subject, adfoin_error_email_message
Filter the recipient, subject, and body of the failure notification. Each receives its default value followed by string $context, array $record, and mixed $return.
add_filter( 'adfoin_error_email_to', function ( $to, $context, $record, $return ) {
return 'in**********@*****le.com';
}, 10, 4 );
Outgoing email
adfoin_pre_email_args and adfoin_email_args
Filter the arguments for emails AFI sends. adfoin_pre_email_args runs before the message is passed through wpautop, and adfoin_email_args runs after, immediately before sending. Both receive array $email and array $args.
Use the pre variant when you want to change the raw message text, and the later one when you want to change headers or the final markup.
Admin interface
adfoin_integration_table_columns and adfoin_integration_table_column_value
Add or modify columns on the Integrations list table.
add_filter( 'adfoin_integration_table_columns', function ( $columns ) {
$columns['owner'] = 'Owner';
return $columns;
} );
add_filter( 'adfoin_integration_table_column_value', function ( $value, $item, $column_name ) {
if ( 'owner' === $column_name ) {
return get_post_meta( $item['id'], 'owner', true );
}
return $value;
}, 10, 3 );
adfoin_log_table_columns and adfoin_log_table_column_value
The same pair for the Logs list table.
adfoin_integration_row_actions
Filters the hover actions under each row on the Integrations screen. Receives array $row_actions and array $item.
adfoin_integration_saved
An action that fires whenever an integration is created or updated, with int $id, array $trigger_data, array $action_data, and array $field_data. Useful for audit logging or for syncing integration definitions to version control.
adfoin_custom_script
An action that fires in the admin footer on AFI screens, for injecting your own JavaScript.
A note on priorities
Several of these hooks pass more than one argument, so remember the fourth parameter to add_filter and add_action. Omitting it is the single most common reason a snippet appears to do nothing: the callback receives only the first argument and the rest arrive as null.