age_gate/submission/success

Fired when an Age Gate submission passes validation (visitor allowed) and dispatched before the method builds and returns the final response (so you can run side-effects like logging, analytics, etc).

Example

functions.php

add_action( 'age_gate/submission/success', 'my_age_gate_success_handler', 10, 3 );
function my_age_gate_success_handler( $hookData, $errors, $customData ) {
    // $hookData and $customData are arrays
    error_log( 'Age Gate passed: ' . wp_json_encode( $hookData ) );
    error_log( 'Extra submitted data: ' . wp_json_encode( $customData ) );
    // e.g. sending information to an external service with wp_remote_post();
}

 

Params

Param Type Description
$hookData array Contains default data from the Age Gate form such and data of birth fields (depending on your validation method)
$errors array Any error data. This should always be an empty array in this hook
$customData array Any other form data such as custom fields added later.