Introduction
For WordPress developers, extensibility is paramount. When implementing sophisticated features like content gating, the ability to hook into a plugin's core processes allows for seamless integration into custom themes, plugins, and third-party systems. WordPress action and filter hooks provide the standardised mechanism for this customisation.
This article serves as a comprehensive reference for leveraging action and filter hooks within the WordPress Gatekeeper Pro plugin. We'll explore how these hooks empower you to extend its robust content restriction, access request, and secure delivery functionalities, ensuring your gated content solution perfectly fits your unique project requirements.
Understanding WordPress Hooks
At the heart of WordPress's extensibility model are action and filter hooks. These allow developers to execute custom code at specific points in WordPress's execution flow or modify data before it's processed.
Action Hooks: These are events triggered by WordPress or a plugin at certain moments, allowing you to "do something" without altering existing data. Think of them as notification points where you can inject your own functions.
Filter Hooks: These allow you to "modify something" before it's returned or used. They provide a mechanism to change data, parameters, or even entire outputs, giving you fine-grained control over how information is handled.
By understanding and utilising these hooks, developers can customise plugin behaviour without directly modifying the plugin's source code. This approach ensures that your customisations are update-safe and maintainable, a critical consideration for any professional WordPress implementation.
Gatekeeper Pro's Extensibility Philosophy
Gatekeeper Pro is engineered with developers in mind, offering multiple avenues for customisation beyond its intuitive user interface. While site owners benefit from its no-code content protection, the plugin also provides a rich developer API, PHP template tags, and, crucially, a comprehensive set of action and filter hooks.
This layered approach ensures that whether you're building a simple client portal or a complex internal knowledge base, you have the tools to integrate gated content into your custom workflows. Hooks are the most powerful of these tools, enabling deep, event-driven customisations that respond to user actions and plugin processes.
Action Hooks for Workflow Customisation
Action hooks in Gatekeeper Pro fire at key moments throughout the content gating workflow. They allow you to trigger external processes, log events, send custom notifications, or integrate with other systems when specific actions occur.
Access Request Lifecycle Hooks
These hooks are invaluable for integrating the access request and approval workflow with CRM systems, marketing automation platforms, or custom logging solutions.
gatekeeper_pro_request_createdFires after a new access request has been saved to the database. This is the earliest point to capture lead data or trigger external notifications.
add_action( 'gatekeeper_pro_request_created', 'my_custom_request_created_action', 10, 2 ); function my_custom_request_created_action( $request_id, $data ) { // $data is an array: post_id, user_name, user_email, user_company, // user_phone, user_location, message, post_type, source_url error_log( 'New request #' . $request_id . ' from ' . $data['user_email'] ); }gatekeeper_pro_request_approvedFires after an access request is approved (via the admin dashboard or one-click email action link) and a token has been generated. This is the most critical integration point for lead qualification and CRM updates.
add_action( 'gatekeeper_pro_request_approved', 'my_custom_request_approved_action', 10, 3 ); function my_custom_request_approved_action( $request_id, $request, $token ) { // $request: full request row array (user_name, user_email, user_company, post_id, etc.) // $token: generated token array (id, token, expires_at, ttl_hours) error_log( 'Request #' . $request_id . ' approved. Token expires: ' . $token['expires_at'] ); }gatekeeper_pro_request_disapprovedFires after an access request is disapproved. Useful for logging rejections, updating CRM statuses, or triggering follow-up actions.
add_action( 'gatekeeper_pro_request_disapproved', 'my_custom_request_disapproved_action', 10, 2 ); function my_custom_request_disapproved_action( $request_id, $request ) { // $request: full request row array error_log( 'Request #' . $request_id . ' for ' . $request['user_email'] . ' disapproved.' ); }
Token Validation Hooks
These hooks fire when tokens are used to access content, allowing for real-time tracking of content consumption and engagement analytics.
gatekeeper_pro_token_validatedFires after a token is successfully validated when a user accesses a gated page. This is invaluable for tracking actual content consumption — it tells you exactly which post was accessed and which token was used.
add_action( 'gatekeeper_pro_token_validated', 'my_custom_token_validated_action', 10, 2 ); function my_custom_token_validated_action( $token, $post_id ) { // $token: full token row array (id, user_email, token_type, access_count, last_accessed, etc.) error_log( 'Token #' . $token['id'] . ' (' . $token['user_email'] . ') accessed post ' . $post_id ); }gatekeeper_pro_content_accessedFires when gated content is displayed to an approved user after token validation. This is the point where the content is actually rendered, making it ideal for view counting and engagement tracking.
add_action( 'gatekeeper_pro_content_accessed', 'my_custom_content_accessed_action', 10, 2 ); function my_custom_content_accessed_action( $post_id, $token ) { // $token: token data array including user_email, token_type, etc. error_log( 'Gated content for post ' . $post_id . ' displayed to ' . $token['user_email'] ); }
File Delivery Hooks
These hooks fire during the secure file delivery process, enabling download tracking, audit logging, and integration with external analytics systems.
gatekeeper_pro_file_downloadedFires after a protected file has been successfully delivered through the secure proxy endpoint. Provides the post ID, file name, and full token data for comprehensive download tracking.
add_action( 'gatekeeper_pro_file_downloaded', 'my_custom_file_download_action', 10, 3 ); function my_custom_file_download_action( $post_id, $file_name, $token ) { // $post_id: the post the file is attached to // $file_name: the name of the downloaded file // $token: full token data array (id, user_email, token_type, etc.) error_log( $token['user_email'] . ' downloaded ' . $file_name . ' from post ' . $post_id ); }gatekeeper_pro_file_streamedFires immediately before a protected file is streamed to the browser via the secure proxy. This is the definitive signal that a file delivery is occurring — ideal for audit logging and real-time analytics.
add_action( 'gatekeeper_pro_file_streamed', 'my_custom_file_streamed_action', 10, 2 ); function my_custom_file_streamed_action( $attachment_id, $token ) { // $attachment_id: WordPress attachment ID of the file // $token: full validated token row (id, user_email, token_type, etc.) error_log( 'Streaming attachment #' . $attachment_id . ' to ' . $token['user_email'] ); }
Filter Hooks for Data Manipulation
Filter hooks allow you to modify data that Gatekeeper Pro uses, from form fields and email content to access logic and token expiry. These are crucial for tailoring the plugin's behaviour to precise specifications.
Form and Field Filters
Customise the native access request form's configurable fields and the data included in submission emails.
gatekeeper_pro_form_fieldsFilters the native form's four configurable fields (phone, company, location, message) before rendering. Each field has
visible,required, andlabelproperties. Use this to conditionally toggle fields or change labels based on post type or other criteria.add_filter( 'gatekeeper_pro_form_fields', 'my_custom_form_fields', 10, 2 ); function my_custom_form_fields( $fields, $post_id ) { // Force company and phone visible + required on 'resource' post type if ( 'resource' === get_post_type( $post_id ) ) { $fields['company']['visible'] = true; $fields['company']['required'] = true; $fields['phone']['visible'] = true; $fields['phone']['required'] = true; } // Relabel the message field if ( isset( $fields['message'] ) ) { $fields['message']['label'] = 'Why do you need access?'; } return $fields; }gatekeeper_pro_submission_form_fieldsFilters the field data included in submission notification emails. Receives the full submitted data and the form source identifier, allowing you to modify what appears in admin and user emails.
add_filter( 'gatekeeper_pro_submission_form_fields', 'my_custom_submission_fields', 10, 3 ); function my_custom_submission_fields( $fields, $data, $form_source ) { // Add a computed field to the email summary $fields['content_requested'] = get_the_title( $data['post_id'] ); return $fields; }
Email Template Filters
Gatekeeper Pro sends five email types: admin notification, request received, approved, disapproved, and expiry warning. Templates live in templates/emails/ and can be overridden in your theme at gatekeeper-pro/emails/. For programmatic control, use the email template filter.
gatekeeper_pro_email_templateFilters the resolved file path for an email template. Runs after the plugin checks for theme overrides, giving you the final say over which template file is loaded. The second parameter is the template name slug.
add_filter( 'gatekeeper_pro_email_template', 'my_custom_email_template', 10, 2 ); function my_custom_email_template( $template_file, $template ) { // Template names: 'admin-notification', 'request-received', 'approved', // 'disapproved', 'expiry-warning' if ( 'approved' === $template ) { $custom = get_stylesheet_directory() . '/gatekeeper-pro/emails/approved-vip.php'; if ( file_exists( $custom ) ) { return $custom; } } return $template_file; }
Access Control and Token Filters
These filters let you dynamically adjust token behaviour and control which post types support gating.
gatekeeper_pro_token_ttlFilters the Time-To-Live (TTL) in hours before a user-facing access token is generated. The third parameter is the full request data array, enabling conditional expiry based on requester details, content type, or any other criteria.
add_filter( 'gatekeeper_pro_token_ttl', 'my_custom_token_expiry', 10, 3 ); function my_custom_token_expiry( $ttl_hours, $post_id, $request ) { // Unlimited access for partner email domains $email = $request['user_email'] ?? ''; if ( str_ends_with( $email, '@partnerdomain.com' ) ) { return 0; // 0 = unlimited } // Short 24-hour window for press releases if ( 'press_release' === get_post_type( $post_id ) ) { return 24; } return $ttl_hours; }gatekeeper_pro_admin_token_ttlFilters the TTL (in seconds) for the HMAC-signed admin approval/disapproval links sent in email notifications. The default is 72 hours (3 days).
add_filter( 'gatekeeper_pro_admin_token_ttl', 'my_custom_admin_ttl' ); function my_custom_admin_ttl( $ttl ) { return 7 * DAY_IN_SECONDS; // Give admins a full week to act }gatekeeper_pro_enabled_post_typesFilters the list of post type slugs that have content gating available. Use this to programmatically add custom post types to gating support, regardless of admin settings.
add_filter( 'gatekeeper_pro_enabled_post_types', 'my_custom_post_types' ); function my_custom_post_types( $post_types ) { if ( ! in_array( 'resource', $post_types, true ) ) { $post_types[] = 'resource'; } return $post_types; }
Display and Output Filters
Modify how Gatekeeper Pro renders gated content on the front end, allowing you to inject custom messaging, branding, or additional markup around locked and unlocked states.
gatekeeper_pro_locked_content_htmlFilters the HTML output for the locked (restricted) content state — the view shown to visitors who have not yet been granted access. Use this to add custom messaging, branding, or lead-generation prompts above the request form.
add_filter( 'gatekeeper_pro_locked_content_html', 'my_custom_locked_html', 10, 2 ); function my_custom_locked_html( $html, $post_id ) { $wrapper = '<div class="my-custom-locked-wrapper">'; $wrapper .= '<h3>This content is restricted</h3>'; $wrapper .= '<p>Submit your details below to request access.</p>'; $wrapper .= $html; $wrapper .= '</div>'; return $wrapper; }gatekeeper_pro_unlocked_content_htmlFilters the HTML output for the unlocked content state — shown to visitors with a valid access token. The third parameter provides the full token data, enabling personalised messaging like welcome greetings or expiry notices.
add_filter( 'gatekeeper_pro_unlocked_content_html', 'my_custom_unlocked_html', 10, 3 ); function my_custom_unlocked_html( $html, $post_id, $token ) { $greeting = '<p class="my-welcome">Welcome back, ' . esc_html( $token['user_email'] ) . '!</p>'; if ( ! empty( $token['expires_at'] ) ) { $greeting .= '<p class="my-expiry">Access expires: ' . esc_html( $token['expires_at'] ) . '</p>'; } return $greeting . $html; }
Leveraging the Gatekeeper Pro Developer API
While hooks provide event-driven customisation, Gatekeeper Pro also exposes a developer API through direct class methods and PHP template tags. These components complement the hook system, allowing you to programmatically interact with the plugin's functionalities.
For instance, you might use an action hook like gatekeeper_pro_request_created to send request details to an external CRM, or to programmatically generate a token using its methods under certain custom conditions. This combination of hooks for reacting to events and API methods for proactive interaction forms a powerful toolkit for advanced developers.
Best Practices for Customisation
When extending Gatekeeper Pro or any WordPress plugin using hooks, adhering to best practices ensures maintainability, performance, and compatibility:
Use a Child Theme or Custom Plugin: Never modify core plugin files directly. All your custom code should reside in a child theme's
functions.phpfile or, ideally, within a dedicated custom plugin.Prioritise Filters for Data, Actions for Side Effects: Use filters when you need to change data or values that the plugin processes. Use actions when you want to execute code in response to an event without directly modifying the primary data flow.
Prefix Your Functions: Always prefix your custom function names (e.g.,
my_custom_function_name) to prevent naming conflicts with other plugins or themes.Document Your Code: Clear comments explain what your customisations do, why they're there, and any dependencies. This is crucial for future maintenance.
Test Thoroughly: After implementing any customisation, rigorously test all affected workflows and edge cases to ensure stability and functionality.
Sanitise and Validate: When dealing with user input or data from external sources, always sanitise and validate to prevent security vulnerabilities.
Real-World Scenarios for Developers
Consider these practical applications for Gatekeeper Pro's hooks:
CRM Integration: Use
gatekeeper_pro_request_createdto push new lead details to Salesforce or HubSpot as soon as a request is submitted.Tiered Token Expiry: Use
gatekeeper_pro_token_ttlto grant unlimited access to partner email domains while keeping short 24-hour windows for time-sensitive content like press releases.Download Analytics: Leverage
gatekeeper_pro_file_downloadedandgatekeeper_pro_file_streamedto feed detailed consumption data into an external analytics dashboard or data warehouse.Custom Notification Workflows: Use
gatekeeper_pro_request_approvedto trigger Slack notifications, SMS alerts (via a third-party service), or marketing automation sequences when high-value content is approved.Conditional Form Fields: Filter
gatekeeper_pro_form_fieldsto force the company and phone fields visible and required on B2B content while keeping a simpler form on blog posts.
Conclusion
WordPress Gatekeeper Pro provides a robust and secure content gating solution, but its true power for developers lies in its extensibility. By offering a comprehensive suite of action and filter hooks, the plugin empowers you to deeply integrate its functionalities into virtually any custom WordPress environment.
Whether you're automating workflows, customising user experiences, or integrating with external systems, understanding and utilising these hooks is key to unlocking the full potential of gated content on your WordPress site. Embrace the developer API and the power of hooks to build truly tailored and sophisticated content access solutions.

