Docs Developer Reference Action Hooks Reference

Action Hooks Reference

Use add_action() in your theme’s functions.php or a custom plugin to hook into ToolDocs™ events.

User Lifecycle

tooldocs_user_logged_in

Fired when a user successfully logs in via any authentication method.

add_action('tooldocs_user_logged_in', function($user_id) {
    // $user_id = ToolDocs user ID
    my_analytics_track('user_login', ['user_id' => $user_id]);
});

tooldocs_user_registered_for_session

Fired when a user completes registration and their session is established.

add_action('tooldocs_user_registered_for_session', function($user_id) {
    my_crm_create_contact($user_id);
});

tooldocs_form_after_submission

Fired after a registration form (document or whitelist) is submitted. Receives the sanitized form data array.

add_action('tooldocs_form_after_submission', function($data) {
    // $data contains: email, first_name, last_name, plus custom fields
    wp_remote_post('https://api.your-crm.com/leads', [
        'body' => json_encode($data),
        'headers' => ['Content-Type' => 'application/json'],
    ]);
});

Download Tracking

td_log_download

Fired when a file is downloaded. The default handler runs at priority 10. Use priority 20+ for custom tracking.

add_action('td_log_download', function($document, $user_id, $source, $is_gated) {
    // $document->id, ->file_name, ->hash, ->gated_hash, ->downloads
    // $source = URL where download was initiated
    // $is_gated = true if accessed via gated hash
}, 20, 4);

td_file_downloaded_track_session

Fired after a download is logged to the database. Used for session-level tracking.

add_action('td_file_downloaded_track_session', function($file_id, $user_id, $context) {
    // $context['session_id']], $context['is_gated'], $context['source']
}, 10, 3);

td_log_pageview

Fired when a page view is tracked.

add_action('td_log_pageview', function($data) {
    // $data['user_id'], $data['page_view_location'], $data['session_id']
});

tooldocs_register_verification_providers

Register custom bot verification providers. Your class must implement BotVerificationInterface.

Related Articles

Was this article helpful?