5. Defender API Docs
WPMU DEV is dedicated to supporting advanced users in every possible way. Our Defender API Documentation is an ongoing project. Information about new commands will be added here as it becomes available.
5.1 Filters & Actions
Copy chapter anchor to clipboardsrc/controller/password-reset.php
/src/component/notfound-lockout.php
/src/component/scan.php
5.1.1 Filter: defender_get_supported_servers
Link to chapter 1Description
Filter. Get supported servers.
Usage
add_filter( ‘defender_get_supported_servers’, ‘custom_defender_filter’ );
Parameters
$servers – array – the list of supported servers
Return
the $servers as an array
Example
5.1.2 Filter: defender_security_tweaks_login-duration_get_duration
Link to chapter 1Description
Filter. Get login duration in days or seconds.
Usage
add_filter( ‘defender_security_tweaks_login-duration_get_duration’, ‘custom_defender_filter’ );
Parameters
$duration – int – duration value
Return
the $duration as int
Example
5.1.3 Filter: defender_php-version_supported_php
Link to chapter 1Description
Filter. Get supported PHP versions.
Usage
add_filter( ‘defender_php-version_supported_php’, ‘custom_defender_filter’ );
Parameters
$supported_php – array – the list of supported PHP versions
Return
the $supported_php as an array
Example
5.1.4 Filter: defender_ssl_verify
Link to chapter 1Description
Filter. Verify SSL argument in an HTTP request.
Usage
add_filter( ‘defender_ssl_verify’, ‘custom_defender_filter’ );
Parameters
$ssl_verify – bool
Return
the $ssl_verify as bool
Example
5.1.5 Filter: wd_audit_settings_keys
Link to chapter 1Description
Filter. Convert the key to the human name.
Usage
add_filter( ‘wd_audit_settings_keys’, ‘custom_defender_filter’ );
Parameters
$settings_keys – array – the list of keys.
Return
the $settings_keys as an array
Example
5.1.6 Filter: wd_audit_enable
Link to chapter 1Description
Filter. Filter “active” status check for Audit Logging.
Usage
add_filter( ‘wd_audit_enable’, ‘custom_defender_filter’ );
Parameters
$enabled – bool
Return
the $enabled as bool
Example
5.1.7 Filter: wd_audit_excluded_post_types
Link to chapter 1Description
Filter. Exclude post types.
Usage
add_filter( ‘wd_audit_excluded_post_types’, ‘custom_defender_audit_excluded_post_types’ );
Parameters
$excluded_post_types – array
Return
$excluded_post_types as array
Example
5.1.8 Filter: wp_defender_audit_hooks
Link to chapter 1Description
Filter. Filter the hook list.
Usage
add_filter(‘wp_defender_audit_hooks’, ‘custom_defender_audit_hooks’);
Parameters
$hooks – array
Return
$hooks as array
Example
If you need to remove someone from the list of hooks.
5.1.9 Filter: wpdef_audit_limit_deleted_logs
Link to chapter 1Description
Filter. Filter to manage the limitation when deleting Audit records.
Usage
add_filter( ‘wpdef_audit_limit_deleted_logs’, ‘custom_wpdef_audit_limit_deleted_logs’ );
Parameters
$limit_deleted_logs – int. 50 is by default.
Return
$limit_deleted_logs as integer.
Example
5.1.10 Action: wd_login_lockout
Link to chapter 1Description
Action after login lockout.
Usage
add_action( ‘wd_login_lockout’, ‘custom_defender_action’ );
Parameters
$model – object – Record the attempt
$scenario – string – One of them: ‘login_fail’, ‘login_lockout’ or ‘login_ban’
Return
No return.
Example
5.1.11 Filter: wpdef_firewall_trusted_proxies
Link to chapter 1Description
Filters the list of trusted proxies.
Usage
add_filter( ‘wpdef_firewall_trusted_proxies’, ‘extend_trusted_proxies’ );
Parameters
$trusted_proxies – array
Return
$trusted_proxies as an array.
Example
5.1.12 Filter: wpdef_firewall_unlockout_expired_time
Link to chapter 1Description
Filters the expired time of the Unlock me feature.
Usage
add_filter(‘wpdef_firewall_unlockout_expired_time’, ‘custom_firewall_unlockout_expired_time’ );
Parameters
$period_and_unit — string.
Return
$period_and_unit as a string.
Example
5.1.13 Filter: wpdef_firewall_unlockout_excluded_reasons
Link to chapter 1Description
Filters the excluded reasons of the Unlock me feature.
Usage
add_filter( ‘wpdef_firewall_unlockout_excluded_reasons’, ‘custom_firewall_unlockout_excluded_reasons’);
Parameters
$excluded_reasons — array.
Return
$excluded_reasons as array.
Example
5.1.14 Filter: wpdef_firewall_unlockout_is_displayed
Link to chapter 1Description
Filters the flag to display the Unlock me feature or not.
Usage
add_filter( ‘wpdef_firewall_unlockout_is_displayed’, ‘custom_firewall_unlockout_is_displayed’ );
Parameters
$is_displayed — bool.
Return
$is_displayed as bool.
Example
5.1.15 Filter: wpdef_firewall_unlockout_attempt_limit
Link to chapter 1Description
Filters the limit of failed attempts.
Usage
add_filter( ‘wpdef_firewall_unlockout_attempt_limit’, ‘custom_firewall_unlockout_attempt_limit’ );
Parameters
$attempt_limit — int.
Return
$attempt_limit as int.
Example
5.1.16 Filter: wpdef_firewall_ip_detection
Link to chapter 1Description
Filter. Filters the HTTP header for IP detection.
Usage
add_filter( ‘wpdef_firewall_ip_detection’, ‘custom_firewall_ip_detection’ );
Parameters
$http_header – string
Return
$http_headeras a string
Example
5.1.17 Action: wd_404_lockout
Link to chapter 1Description
Action after ‘Not found’ lockout.
Usage
add_action( ‘wd_404_lockout’, ‘custom_defender_action’ );
Parameters
$model – Lockout_Ip – The Lockout_Ip object representing the IP address being locked.
$scenario – string – The scenario of the IP lockout (“normal” or “blacklist”).
$uri – string – The URI associated with the 404 lockout.
Return
No return.
Example
5.1.18 Action: wd_blacklist_this_ip
Link to chapter 1Description
Action. Perform an action when an IP is blocked.
Usage
add_action( ‘wd_blacklist_this_ip’, ‘custom_defender_action’ );
Parameters
$ip – string – a new IP for blacklist
Return
No return.
Example
5.1.19 Action: defender_ip_lockout_action_assets
Link to chapter 1Description
Action. Add additional script or style assets for IP Lockouts.
Usage
add_action( ‘defender_ip_lockout_action_assets’, ‘custom_defender_action’ );
Parameters
No parameters.
Return
No return.
Example
5.1.20 Action: wd_before_lockout
Link to chapter 1Description
Action before any lockouts.
Usage
add_action( ‘wd_before_lockout’, ‘custom_defender_action’ );
Parameters
$ip – string
Return
No return.
Example
5.1.21 Filter: wpdef_firewall_send_logs_to_api
Link to chapter 1Description
Filter. Filters whether to enable/disable sending Firewall logs to API.
Usage
add_filter( ‘wpdef_firewall_send_logs_to_api’, ‘custom_firewall_send_logs_to_api’ );
Parameters
$status – bool
Return
$status as bool
Example
5.1.22 Filter: ip_lockout_logs_store_backward
Link to chapter 1Description
Filter. Count days for IP logs to be saved to DB
Usage
add_filter( ‘ip_lockout_logs_store_backward’, ‘custom_defender_filter’ );
Parameters
$storage_days – string|int – storage days
Return
the $storage_days as string|int.
Example
5.1.23 Filter: ip_lockout_default_whitelist_ip
Link to chapter 1Description
Filter. Get the list of default allowlisted IP addresses.
Usage
add_filter( ‘ip_lockout_default_whitelist_ip’, ‘custom_defender_filter’ );
Parameters
$ips – array – the default IPs that need to whitelisteda
Return
the $ips as an array
Example
5.1.24 Filter: wd_user_agents_enable
Link to chapter 1Description
Filter. Enable or disable of the User Agent Banning feature.
Usage
add_filter( ‘wd_user_agents_enable’, ‘custom_defender_filter’ );
Parameters
$enabled – boolean
Return
boolean
Example
add_filter( 'wd_user_agents_enable', '__return_false' );
5.1.25 Filter: wd_ip_to_country_api
Link to chapter 1Description
Filter. Extend country detection with third-party services.
Usage
add_filter( ‘wd_ip_to_country_api’, ‘custom_defender_ip_to_country_api’, 11, 2 );
Parameters
$country_result – bool
$ip – string – IPV4 or IPV6 address
Return
$country_result as bool|array.
Example
5.1.26 Action: wd_user_agent_before_block
Link to chapter 1Description
Action. Fires before User Agent is blocked.
Usage
add_action( ‘wd_user_agent_before_block’, ‘custom_defender_action’ );
Parameters
$user_agent – string. Value from $_SERVER[‘HTTP_USER_AGENT’].
$ip – string. User IP.
$reason – string. Reason for blocking.
Return
No return
Example
5.1.27 Action: wd_user_agent_lockout
Link to chapter 1Description
Action. Action after User Agent lockout.
Usage
add_action( ‘wd_user_agent_lockout’, ‘custom_defender_action’ );
Parameters
$model – object.
$scenario – string.
Return
No return
Example
5.1.28 Filter: wd_user_agent_additional_check
Link to chapter 1Description
Filter. Additional conditions for User Agent.
Usage
add_filter( ‘wd_user_agent_additional_check’, ‘custom_defender_filter’, 11, 3 );
Parameters
$is_allow – bool
$user_agent – string
$ip – string
Return
No return
Example
5.1.29 Filter: wd_current_user_agent
Link to chapter 1Description
Filter. Filter user agent.
Usage
add_filter( ‘wd_current_user_agent’, ‘custom_defender_filter’ );
Parameters
$user_agent – string. Value from $_SERVER[‘HTTP_USER_AGENT’].
Return
$user_agent as string.
Example
5.1.30 Filter: wd_update_maxmind_database
Link to chapter 1Description
Filter. Allows update or remove the database of MaxMind automatic and periodically.
Usage
add_filter( ‘wd_update_maxmind_database’, ‘custom_defender_filter’ );
Parameters
$flag – bool
Return
the $flag as boolean
Example
add_filter( 'wd_update_maxmind_database', '__return_false' );
5.1.31 Action: wpdef_update_geoip
Link to chapter 1Description
Action. Update the geolocation database.
Usage
add_action( ‘wpdef_update_geoip’, ‘custom_defender_action’ );
Parameters
No parameters
Return
No return
Example
5.1.32 Filter: wpdef_antibot_enabled
Link to chapter 1Description
Filter. Filter to enable or disable the Antibot module.
Usage
add_filter( ‘wpdef_antibot_enabled’, ‘disable_antibot’ );
Parameters
$is_enabled – bool
Return
$is_enabled as bool
Example
5.1.33 Filter: wpdef_firewall_whitelist_server_public_ip_enabled
Link to chapter 1Description
Filter. Filter to enable/disable fetching and storing server public IP
Usage
add_filter( ‘wpdef_firewall_whitelist_server_public_ip_enabled’, ‘disable_whitelist_server_public_ip’ );
Parameters
$enabled – bool
Return
$enabled as bool.
Example
5.1.34 Filter: wpdef_firewall_whitelist_mainwp_dashboard_public_ip_enabled
Link to chapter 1Description
Filter. Filter to enable/disable whitelisting the MainWP Dashboard site’s public IP.
Usage
add_filter( ‘wpdef_firewall_whitelist_server_public_ip_enabled’, ‘disable_whitelist_server_public_ip’ );
Parameters
$enabled – bool
Return
$enabled as bool.
Example
5.1.35 Filter: wpdef_antibot_global_firewall_ip_log
Link to chapter 1Description
Filter. Filter whether IP logging is enabled.
Usage
add_filter( ‘wpdef_antibot_global_firewall_ip_log’, ‘custom_wpdef_antibot_global_firewall_ip_log’ );
Parameters
$enabled – bool
Return
$enabled as bool.
Example
5.1.36 Filter: wp_defender_2fa_user_enabled
Link to chapter 1Description
Filter. Check if the 2FA option is enabled for a specific user.
Usage
add_filter( ‘wp_defender_2fa_user_enabled’, ‘custom_defender_filter’, 10, 2 );
Parameters
$is_enabled – int. One of them: 1 or 0 $user_id – int.
Return
the $is_enabled as int
Example
5.1.37 Action: wd_2fa_enabled_provider_slugs
Link to chapter 1Description
Action. Fires when 2fa providers are enabled.
Usage
add_action( ‘wd_2fa_enabled_provider_slugs’, ‘custom_defender_action’);
Parameters
$provider_slugs – array. The slug list of enabled providers.
Return
No return.
Example
5.1.38 Filter: wd_2fa_enable
Link to chapter 1Description
Filter. Filter the Defender > 2FA module’s state.
Usage
add_filter( ‘wd_2fa_enable ‘, ‘custom_wd_2fa_enable’ );
Parameters
$enabled – bool
Return
$enabled as bool
Example
5.1.39 Action: wpmu_2fa_login
Link to chapter 1Description
Action. Fires after successful login via 2fa.
Usage
add_action( ‘wpmu_2fa_login’, ‘custom_defender_action’, 10, 2);
Parameters
$user_id – string. User ID.
$auth_method – string. 2FA auth method.
Return
No return
Example
5.1.40 Filter: wd_2fa_providers
Link to chapter 1Description
Filter. Filter the supplied providers.
Usage
add_filter( ‘wd_2fa_providers’, ‘custom_defender_filter’ );
Parameters
$classes – array
Return
the $classes as array
Example
5.1.41 Filter: wd_2fa_enabled_providers_for_user
Link to chapter 1Description
Filter. Filter the enabled 2FA providers for this user.
Usage
add_filter( ‘wd_2fa_enabled_providers_for_user’, ‘custom_defender_filter’ );
Parameters
$enabled_providers – array
$user_id – int
Return
the $enabled_providers as array
Example
5.1.42 Action: wd_2fa_init_provider_totp
Link to chapter 1Description
Action. Fires before user options are shown.
Usage
add_action( ‘wd_2fa_init_provider_totp’, ‘custom_defender_action’ );
Parameters
$user – object
Return
No return
Example
5.1.43 Action: wd_2fa_init_provider_backup-codes
Link to chapter 1Description
Action. Fires before user options are shown.
Usage
add_action( ‘wd_2fa_init_provider_backup-codes’, ‘custom_defender_action’ );
Parameters
$user – object
Return
No return
Example
5.1.44 Action: wd_2fa_init_provider_fallback-email
Link to chapter 1Description
Action. Fires before user options are shown.
Usage
add_action( ‘wd_2fa_init_provider_fallback-email’, ‘custom_defender_action’ );
Parameters
$user – object
Return
No return
Example
5.1.45 Action: wd_2fa_user_options_totp
Link to chapter 1Description
Action. Fires before user options are shown.
Usage
add_action( ‘wd_2fa_user_options_totp’, ‘custom_defender_action’ );
Parameters
$user – object
Return
No return
Example
5.1.46 Action: wd_2fa_user_options_backup-codes
Link to chapter 1Description
Action. Fires before user options are shown.
Usage
add_action( ‘wd_2fa_user_options_backup-codes’, ‘custom_defender_action’ );
Parameters
$user – object
Return
No return
Example
5.1.47 Action: wd_2fa_user_options_fallback-email
Link to chapter 1Description
Action. Fires before user options are shown.
Usage
add_action( ‘wd_2fa_user_options_fallback-email’, ‘custom_defender_action’ );
Parameters
$user – object
Return
No return
Example
5.1.48 Action: wd_2fa_user_options_biometric
Link to chapter 1Description
Action. Fires after user options are shown.
Usage
add_action( ‘wd_2fa_user_options_biometric’, ‘custom_defender_action’ );
Parameters
$user – object
Return
No return.
Example
5.1.49 Action: wd_2fa_form_before
Link to chapter 1Description
Action before the display of 2FA user settings on frontend.
Usage
add_action( ‘wd_2fa_form_before’, ‘custom_defender_action’ );
Parameters
No parameters.
Return
No return.
Example
5.1.50 Action: wd_2fa_form_after
Link to chapter 1Description
Action after the display of 2FA user settings on frontend.
Usage
add_action( ‘wd_2fa_form_after’, ‘custom_defender_action’ );
Parameters
No parameters.
Return
No return.
Example
5.1.51 Filter: wd_2fa_form_when_not_logged_in
Link to chapter 1Description
Filter. Display text instead of 2FA user settings for an unlogged user on the frontend.
Usage
add_filter( ‘wd_2fa_form_when_not_logged_in’, ‘custom_defender_filter’ );
Parameters
$text – string. By default, it returns no text.
Return
$text as a string
Example
5.1.52 Action: wd_woocommerce_save_2fa_details
Link to chapter 1Description
Action. Save 2FA user settings on WooCommerce > My Account page.
Usage
add_action( ‘wd_woocommerce_save_2fa_details’, ‘custom_defender_action’ );
Parameters
$user_id – int – The current user ID.
Return
No return.
Example
5.1.53 Filter: wd_2fa_enable_attempts
Link to chapter 1Description
Filter. Enable or disable 2FA attempts during login.
Usage
add_filter( ‘wd_2fa_enable_attempts’, ‘custom_defender_filter’ );
Parameters
$enable – bool
Return
$enable as bool.
Example
5.1.54 Filter: wd_2fa_attempt_limit
Link to chapter 1Description
Filter. Get an attempt limit.
Usage
add_filter( ‘wd_2fa_attempt_limit’, ‘custom_defender_filter’ );
Parameters
$attempt_limit – int
Return
$attempt_limit as int.
Example
5.1.55 Filter: wd_2fa_time_limit
Link to chapter 1Description
Filter. Get time limit.
Usage
add_filter( ‘wd_2fa_time_limit’, ‘custom_defender_filter’ );
Parameters
$time_limit – int
Return
$time_limit as int.
Example
5.1.56 Action: wd_2fa_lockout
Link to chapter 1Description
Action after 2FA lockout.
Usage
add_action( ‘wd_2fa_lockout’, ‘custom_defender_action’ );
Parameters
$user_id – int. User ID
$message – string. The message on the blocked page
$time_limit – int. Remaining countdown time in seconds.
Return
No return.
Example
5.1.57 Filter: wp_mask_login_enable
Link to chapter 1Description
Filter. Enable or disable the Mask Login feature.
Usage
add_filter( ‘wd_mask_login_enable’, ‘custom_defender_filter’ );
Parameters
$data – array
Return
boolean
Example
add_filter( 'wd_mask_login_enable', '__return_false' );
5.1.58 Filter: wd_mask_login_skip_site_url_filter
Link to chapter 1Description
Filter. Filters the list of plugins for which ‘site_url’ filter should be skipped.
Usage
add_filter( ‘wd_mask_login_skip_site_url_filter ‘, ‘skip_site_url_filter’ );
Parameters
$plugins – array
Return
$plugins as array
Example
5.1.59 Filter: wd_mask_login_bot_list
Link to chapter 1Description
Filter. Add/remove bots from the list for Mask Login.
Usage
add_filter( ‘wd_mask_login_bot_list ‘, ‘custom_mask_login_bot_list’ );
Parameters
$bot_list – array
Return
$bot_list as array
Example
5.1.60 Filter: wd_mask_login_is_bot_request
Link to chapter 1Description
Filter. Result of bot request check.
Usage
add_filter( ‘wd_mask_login_is_bot_request’, ‘custom_mask_login_is_bot_request’ );
Parameters
$is_bot_req – bool
Return
$is_bot_req as bool
Example
5.1.61 Filter: wd_login_strict_slugs
Link to chapter 1Description
Filter. Filter strict slugs.
Usage
add_filter( ‘wd_login_strict_slugs’, ‘custom_defender_filter’ );
Parameters
$slugs – array – the list of the slugs
Return
the $slugs as an array
Example
5.1.62 Filter: wd_login_slugs
Link to chapter 1Description
Filter. Filter non-strict slugs.
Usage
add_filter( ‘wd_login_slugs’, ‘custom_defender_filter’ );
Parameters
$slugs – array – the list of the slugs
Return
the $slugs as an array
Example
5.1.63 Filter: defender_redirect_login
Link to chapter 1Description
Filter. Redirect to the page.
Usage
add_filter( ‘defender_redirect_login’, ‘custom_defender_filter’, 10, 3 );
Parameters
$url – string $raw_url – string $user – object – User object
Return
the $url string.
Example
5.1.64 Filter: wd_mask_login_is_allowed_path
Link to chapter 1Description
Filter. Filter to allow whitelisting paths from login masking.
Usage
add_filter( ‘wd_mask_login_is_allowed_path’, ‘custom_defender_filter’ );
Parameters
$allowed – bool
$path – string
Return
the $allowed as bool
Example
5.1.65 Filter: wd_login_forbidden_slugs
Link to chapter 1Description
Filter. Filter forbidden slugs on the Login page.
Usage
add_filter( ‘wd_login_forbidden_slugs’, ‘custom_defender_filter’ );
Parameters
$slugs – array
Return
$slugs as array
Example
5.1.66 Filter: wpdef_maybe_redirect_to_mask_login_url
Link to chapter 1Description
Filter. Filter to redirect current URL to Mask Login URL.
Usage
add_filter( ‘wpdef_maybe_redirect_to_mask_login_url’, ‘custom_defender_filter’ );
Parameters
$allowed – bool
$current_url – string
Return
the $allowed as boolean
Example
5.1.67 Filter: wd_head_request_ttl
Link to chapter 1Description
Filter. Get TTL.
Usage
add_filter( ‘wd_head_request_ttl’, ‘custom_defender_filter’ );
Parameters
$ttl – null|int|false
Return
the $ttl string
Example
5.1.68 Filter: wd_permissions_policy_directives
Link to chapter 1Description
Filter. Filter directives of Permissions-Policy header.
Usage
add_filter( ‘wd_permissions_policy_directives’, ‘custom_defender_filter’ );
Parameters
$directives – array
Return
the $directives as array
Example
5.1.69 Action: defender_recipient_added
Link to chapter 1Description
Action. After adding recipients
Usage
add_action(‘defender_recipient_added’, ‘custom_defender_action’, 10, 2 );
Parameters
$email – string
$name – string
Return
No return.
Example
5.1.70 Action: defender_notify
Link to chapter 1Description
Action. Notify users about results from Scan and Firewall modules.
Usage
add_action( ‘defender_notify’, ‘custom_defender_action’ );
Parameters
$slug – string – One of them: ‘firewall-notification’, ‘malware-notification’
$model – module object
Return
No return.
Example
5.1.71 Filter: wd_unlock_noreply_email
Link to chapter 1Description
Filter. Filters [email protected] for the Unlock me feature
Usage
add_filter( ‘wd_unlock_noreply_email’, ‘custom_wd_unlock_noreply_email’ );
Parameters
$no_reply_email — string.
Return
$no_reply_email as string.
Example
5.1.72 Filter: wd_confirm_noreply_email
Link to chapter 1Description
Filter. Change email for confirmation.
Usage
add_filter( ‘wd_confirm_noreply_email’, ‘custom_defender_filter’ );
Parameters
$no_reply_email – string
Return
the $no_reply_email as string.
Example
5.1.73 Filter: wd_subscribe_noreply_email
Link to chapter 1Description
Filter. Change email for subscription.
Usage
add_filter( ‘wd_subscribe_noreply_email’, ‘custom_defender_filter’ );
Parameters
$no_reply_email – string
Return
the $no_reply_email as string.
Example
5.1.74 Filter: wd_unsubscribe_noreply_email
Link to chapter 1Description
Filter. Change email to unsubscribe.
Usage
add_filter( ‘wd_unsubscribe_noreply_email’, ‘custom_defender_filter’ );
Parameters
$no_reply_email – string
Return
the $no_reply_email as string.
Example
5.1.75 Filter: wd_scan_threshold
Link to chapter 1Description
Filter. Filter to override scan threshold period.
Usage
add_filter( ‘wd_scan_threshold’, ‘custom_defender_filter’ );
Parameters
$threshold_period – string. Any valid relative Date and Time formats.
Return
the $threshold_period as string
Example
5.1.76 Filter: wd_scan_excluded_plugin_slugs
Link to chapter 1Description
Filter. Exclude plugin slugs.
Usage
add_filter( ‘wd_scan_excluded_plugin_slugs’, ‘custom_defender_filter’ );
Parameters
$slugs – array
Return
array
Example
5.1.77 Action: wpdef_fixed_scan_issue
Link to chapter 1Description
Action. Fired when the scan issue is fixed.
Usage
add_action( ‘wpdef_fixed_scan_issue ‘, ‘custom_defender_fixed_scan_issue’ );
Parameters
$slugs – array
Return
$issue_type – string. Scan issue type, e.g. plugin_integrity, malware or vulnerability.
$action – string. Scan action, e.g. delete or resolve.
Example
5.1.78 Filter: wd_display_vulnerability_warnings
Link to chapter 1Description
Filter. Enable or disable of the view of vulnerability warnings.
Usage
add_filter( ‘wd_display_vulnerability_warnings’, ‘custom_defender_filter’ );
Parameters
$enabled – boolean
Return
boolean
Example
add_filter( 'wd_display_vulnerability_warnings', '__return_true' );
5.1.79 Filter: wd_password_protection_enable
Link to chapter 1Description
Filter. Enable or disable the Pwned Passwords feature.
Usage
add_filter( ‘wd_password_protection_enable’, ‘custom_defender_filter’ );
Parameters
$data – array
Return
boolean
Example
add_filter( 'wd_password_protection_enable', '__return_false' );
5.1.80 Filter: wd_password_reset_active
Link to chapter 1Description
Filter. Enable or disable the Password Reset feature.
Usage
add_filter( ‘wd_password_reset_active’, ‘custom_defender_filter’ );
Parameters
$data – array
Return
boolean
Example
add_filter( 'wd_password_reset_active', '__return_false' );
5.1.81 Action: wd_forced_reset_password_url
Link to chapter 1Description
Action. The forced url to password reset page.
Usage
add_action( ‘wd_forced_reset_password_url’, ‘custom_defender_action’ );
Parameters
$url – string. The reset password page that a user is redirected.
$action – string. Possible values: password_reset or password_protection.
Return
No return.
Example
5.1.82 Filter: wd_strong_password_enable
Link to chapter 1Description
Filter. Filter to enable/disable ‘Strong Passwords’ option.
Usage
add_filter( ‘wd_strong_password_enable’, ‘custom_disable_wd_strong_password’ );
Parameters
$enabled – bool
Return
$enabled as bool.
Example
5.1.83 Filter: wd_recaptcha_enable
Link to chapter 1Description
Filter. Enable or disable the Google reCAPTCHA feature.
Usage
add_filter( ‘wd_recaptcha_enable’, ‘custom_defender_filter’ );
Parameters
$data – array
Return
boolean
Example
add_filter( 'wd_recaptcha_enable', '__return_false' );
5.1.84 Action: wd_recaptcha_before_actions
Link to chapter 1Description
Action. Extra conditions before the reCAPTCHA process.
Usage
add_action( ‘wd_recaptcha_before_actions’, ‘custom_defender_action’ );
Parameters
$condition – bool.
Return
No return.
Example
5.1.85 Action: wd_recaptcha_after_actions
Link to chapter 1Description
Action. Extra conditions after the reCAPTCHA process.
Usage
add_action( ‘wd_recaptcha_after_actions’, ‘custom_defender_action’ );
Parameters
$condition – bool.
Return
No return.
Example
5.1.86 Filter: wd_recaptcha_excluded_requests
Link to chapter 1Description
Filter. Exclude url requests for which Google reCAPTCHA may be displayed.
Usage
add_filter( ‘wd_recaptcha_excluded_requests’, ‘custom_defender_filter’ );
Parameters
$data – array. Array of requests.
Return
array
Example
5.1.87 Filter: wd_recaptcha_check_result
Link to chapter 1Description
Filter. Exclude url requests for which Google reCAPTCHA may be displayed.
Usage
add_filter( ‘wd_recaptcha_check_result’, ‘custom_defender_filter’ );
Parameters
$result – bool. The result after the reCAPTCHA API response.
$form – string. Form slug, e.g. ‘default_comments’ or ‘login_form’.
Return
bool
Example
5.1.88 Filter: wd_recaptcha_require_valid_comment
Link to chapter 1Description
Filter. Display a custom error message.
Usage
add_filter( ‘wd_recaptcha_require_valid_comment’, ‘custom_defender_filter’ );
Parameters
$error_message – string. The text that is displayed on failure for the default comment form.
Return
bool
Example
5.1.89 Filter: wd_recaptcha_remote_ip
Link to chapter 1Description
Filter. Send the current IP to the reCAPTCHA API.
Usage
add_filter( ‘wd_recaptcha_remote_ip’, ‘custom_defender_filter’ );
Parameters
$ip – string.
Return
bool
Example
5.1.90 Action: wd_recaptcha_extra_assets
Link to chapter 1Description
Action. Add additional script or style assets for reCAPTCHA module.
Usage
add_action( ‘wd_recaptcha_extra_assets’, ‘custom_defender_action’ );
Parameters
None
Return
None
Example
5.1.91 Filter: wd_recaptcha_excluded_handles
Link to chapter 1Description
Filter. Filter to exclude scripts from any plugin to display Google reCAPTCHA.
Usage
add_filter( ‘wd_recaptcha_excluded_handles’, ‘custom_wd_recaptcha_excluded_handles’ );
Parameters
$plugin_script_handles – array
Return
$plugin_script_handles as array.
Example
5.1.92 Action: wp_defender
Link to chapter 1Description
Action. Run after the activation of the Defender plugin.
Usage
add_action( ‘wp_defender’, ‘custom_defender_action’ );
Parameters
No parameters.
Return
No return.
Example
5.1.93 Filter: defender_deprecated_function_trigger_error
Link to chapter 1Description
Filter. Filters whether to trigger an error for deprecated functions
Usage
add_filter( ‘defender_deprecated_function_trigger_error ‘, ‘custom_defender_deprecated_function_trigger_error’ );
Parameters
$is_trigger – bool
Return
$is_trigger as bool
Example
5.1.94 Action: wd_settings_update
Link to chapter 1Description
Action. Handle plugin settings update.
Usage
add_action( ‘wd_settings_update’, ‘custom_defender_action’, 10, 2);
Parameters
$old_values – array. The old option values.
$new_values – array. The new option values.
Return
No return.
Example
5.1.95 Action: defender_enqueue_assets
Link to chapter 1Description
Action. Enqueue assets and display data.
Usage
add_action( ‘defender_enqueue_assets’, ‘custom_defender_action’ );
Parameters
No parameters.
Return
No return.
Example
5.1.96 Filter: defender_get_times_interval
Link to chapter 1Description
Filter. Get time interval.
Usage
add_filter( ‘defender_get_times_interval’, ‘custom_defender_filter’ );
Parameters
$interval – array
Return
the $interval array.
Example
5.1.97 Filter: defender_user_ip
Link to chapter 1Description
Filter. Filter user IP.
Usage
add_filter( ‘defender_user_ip’, ‘custom_defender_filter’ );
Parameters
$ip – string
Return
the $ip string
Example
5.1.98 Filter: wp_defender_advanced_tools_data
Link to chapter 1Description
Filter. Get and update frontend data for Masc Login and Security Headers pages.
Usage
add_filter( ‘wp_defender_advanced_tools_data’, ‘custom_defender_filter’ );
Parameters
$data – array
Return
the $data array
Example
5.1.99 Filter: wd_display_rating
Link to chapter 1Description
Filter. Was the button ‘Rate Defender’ clicked or not?
Usage
add_filter( ‘wd_display_rating’, ‘custom_defender_filter’ );
Parameters
$flag – bool
Return
the $flag as bool
Example
5.1.100 Filter: wd_dismiss_rating
Link to chapter 1Description
Filter. Was the button ‘Maybe later’ clicked or not?
Usage
add_filter( ‘wd_dismiss_rating’, ‘custom_defender_filter’ );
Parameters
$flag – bool
Return
the $flag as bool
Example
5.1.101 Filter: wpdef_clear_logs_time_limit
Link to chapter 1Description
Filter. Filter time limit to clear old logs.
Usage
add_filter( ‘wpdef_clear_logs_time_limit’, ‘custom_defender_filter’ );
Parameters
$time_limit – int
Return
the $time_limit as int
Example
5.1.102 Filter: wd_countries
Link to chapter 1Description
Filter. Filter countries.
Usage
add_filter( ‘wd_countries’, ‘custom_defender_filter’ );
Parameters
$countries – array
Return
the $countries as array
Example
5.2 WP-CLI
Copy chapter anchor to clipboardDefender includes WP-CLI integration, enabling command-line access to common tasks. See the list of supported commands below.
5.2.1 Malware Scanning
Link to chapter 2Command
wp defender scan [command] [–type=]
Parameters
Examples
Clear completed Malware Scan entries from Scheduled Actions logs:
wp defender scan clear_logs
Run full Defender filescan:
wp defender scan run
Run full Defender filescan and show full scan results:
wp defender scan run --type=detailed
Run full Defender filescan and ignore all issues:
wp defender scan ignore
Run full Defender filescan and unignore all issues:
wp defender scan unignore
Run full Defender filescan and delete all unknown or modified files/directories in WordPress core, plugins and themes, and all files with suspicious functions found:
wp defender scan delete
Run full Defender filescan and resolve all possible issues:
wp defender scan resolve
Run full Defender filescan and ignore all unknown/modified file issues found in WordPress core:
wp defender scan ignore --type=core_integrity
Run full Defender filescan and unignore all unknown/modified file issues found in WordPress core:
wp defender scan unignore --type=core_integrity
Run full Defender filescan and delete all unknown files/directories in WordPress core:
wp defender scan delete --type=core_integrity
Run full Defender filescan and resolve all unknown/modified file issues found in WordPress core:
wp defender scan resolve --type=core_integrity
Run full Defender filescan and ignore all unknown/modified file issues found in plugins from wordpress.org:
wp defender scan ignore --type=plugin_integrity
Run full Defender filescan and unignore all unknown/modified file issues found in plugins from wordpress.org:
wp defender scan unignore --type=plugin_integrity
Run full Defender filescan and delete all unknown files/directories found in plugins from wordpress.org:
wp defender scan delete --type=plugin_integrity
Run full Defender filescan and resolve all unknown/modified file issues found in plugins from wordpress.org:
wp defender scan resolve --type=plugin_integrity
Run full Defender filescan and ignore all published vulnerability issues found in plugins and themes:
wp defender scan ignore --type=vulnerability
Run full Defender filescan and unignore all published vulnerability issues found in plugins and themes:
wp defender scan unignore --type=vulnerability
Run full Defender filescan and delete all files with published vulnerability issues found in plugins and themes:
wp defender scan delete --type=vulnerability
Run full Defender filescan and resolve all possible published vulnerability issues found in plugins and themes:
wp defender scan resolve --type=vulnerability
Run full Defender filescan and ignore all suspicious code issues found in plugins and themes:
wp defender scan ignore --type=suspicious_code
Run full Defender filescan and unignore all suspicious code issues found in plugins and themes:
wp defender scan unignore --type=suspicious_code
Run full Defender filescan and delete all files with suspicious code issues found in plugins and themes:
wp defender scan delete --type=suspicious_code
Run full Defender filescan and resolve all possible suspicious code issues found in plugins and themes:
wp defender scan resolve --type=suspicious_code
5.2.2 Audit Logging
Link to chapter 2Command
wp defender audit [command]
Parameters
Examples
Delete all Audit Logs from the database and fetch a fresh list of Audit Logs from the Audit API after reloading Defender’s Audit Logging page:
wp defender audit reset
5.2.3 Firewall
Link to chapter 2Command
wp defender firewall [command] [arg_1] [arg_2] –ips=[ips]
Parameters
Examples
Clear all IP addresses from the IP allowlist:
wp defender firewall clear ip allowlist
Clear all IP addresses from the IP blocklist:
wp defender firewall clear ip blocklist
Clear all IP addresses from the Locations allowlist:
wp defender firewall clear ip country_allowlist
Clear all IP addresses from the Locations blocklist:
wp defender firewall clear ip country_blocklist
Clear all files from the 404 allowlist:
wp defender firewall clear files allowlist
Clear all files from the 404 blocklist:
wp defender firewall clear files blocklist
Clear MaxMind license key:
wp defender firewall clear maxmind license_key
Unblock a single IP address:
wp defender firewall unblock ip lockout --ips=127.0.0.1
Unblock multiple IP addresses::
wp defender firewall unblock ip lockout --ips=127.0.0.1,255.255.255.255
Clear all User Agents from the allowlist:
wp defender firewall clear user_agent allowlist
Clear all User Agents from the blocklist:
wp defender firewall clear user_agent blocklist
Activate Login Protection submodule:
wp defender firewall activate submodule login_protection
Activate 404 Detection submodule:
wp defender firewall activate submodule 404_detection
Activate User Agent Banning submodule:
wp defender firewall activate submodule user_agent
Deactivate Login Protection submodule:
wp defender firewall deactivate submodule login_protection
Deactivate 404 Detection submodule:
wp defender firewall deactivate submodule 404_detection
Deactivate User Agent Banning submodule:
wp defender firewall deactivate submodule user_agent
Get the list of all user agents:
wp defender firewall list user_agent all
Get the list of user agents on the allowlist:
wp defender firewall list user_agent allowlist
Get the list of user agents on the blocklist:
wp defender firewall list user_agent blocklist
5.2.4 Mask Login
Link to chapter 2Command
wp defender mask_login [command]
Parameters
Examples
Clear the Mask Login URI & reset to default:
wp defender mask_login clear
5.2.5 Security Headers
Link to chapter 2Command
wp defender security_headers [command]
Parameters
Examples
Check for all security headers:
wp defender security_headers check
Activate all security headers:
wp defender security_headers activate
Deactivate all security headers:
wp defender security_headers deactivate
5.2.6 Password Reset
Link to chapter 2Command
wp defender password_reset [command]
Parameters
Examples
Force password reset for all currently selected user roles:
wp defender password_reset force
Undo the password reset for all currently selected user roles:
wp defender password_reset undo
5.2.7 Google reCAPTCHA
Link to chapter 2Command
wp defender google_recaptcha [command]
Parameters
Examples
Activate Google reCAPTCHA module:
wp defender google_recaptcha activate
Deactivate Google reCAPTCHA module:
wp defender google_recaptcha deactivate
Clear data from Google reCAPTCHA module (reset to default settings):
wp defender google_recaptcha clear
5.2.8 Settings
Link to chapter 2Command
wp defender settings [command]
Parameters
Examples
Reset all plugin settings and data:
wp defender settings reset
5.2.9 Logs
Link to chapter 2Command
wp defender logs [command]
Parameters
Examples
Delete all log entries older than 7 days:
wp defender logs delete
5.3 Modified or Deprecated Hooks
Copy chapter anchor to clipboardThis chapter contains information related to any actions or filters that may be modified or removed due to changes in plugin functionality.
5.3.1 Changes in Version 4.2.0
Link to chapter 3Below is the list of hooks that are deprecated in this version:
Deprecated Filters
wd_mask_login_bot_list
wd_mask_login_is_bot_request
5.3.2 Changes in Version 5.1.0
Link to chapter 3Below is the list of hooks that are deprecated in this version:
Deprecated Filters
wpdef_firewall_gathered_ips
5.4 Get Support
Copy chapter anchor to clipboardIf you still have questions or need assistance after reading this document, please don’t hesitate to contact our support superheroes using the available options under the Support tab in your Hub or via the Support tab in your WPMU DEV Dashboard.