Documentation / Hooks and Filters
Hooks and Filters
Overview
Teydea Login Security provides PHP filters and actions that allow developers to extend or modify the plugin’s behavior, and JavaScript filters that change its settings screen. These hooks follow standard WordPress conventions. The REST API routes the settings screen calls are listed at the end.
For programmatic access that does not require writing PHP, see Abilities API and MCP.
PHP Filters
password_requirements__is_user_excluded_from_policy
Exclude specific users from all password policy enforcement. This is useful for users managed externally, such as those who log in through an SSO provider.
Parameters:
bool $is_excluded— Whether the user is excluded from the password policy. Defaultfalse.?WP_User $user— The user object, ornullif not available.
Return: bool — true to exclude the user, false to apply the policy.
add_filter(
'password_requirements__is_user_excluded_from_policy',
function ( bool $is_excluded, ?WP_User $user ): bool {
// Exclude users with a specific meta value (e.g., SSO users).
if ( $user instanceof WP_User && get_user_meta( $user->ID, 'is_sso_user', true ) ) {
return true;
}
return $is_excluded;
},
10,
2
);
password_requirements__is_password_change_compelled
Declare that the password change a user is facing is forced on them rather than chosen by them. A compelled change is exempt from the minimum password age rule, so the user is never sent to a reset form that then refuses the reset. See Age Rules.
The plugin already treats an expired password, a reset key it has issued for the account, and a change driven by somebody with the standing to edit the account as compelled. Use this filter when a reset is driven by machinery the plugin cannot observe — an external identity provider, or a companion plugin enforcing its own reset schedule.
(PRO) Returning true also exempts an existing account from refusal when the bundled weaklist cannot be read and weaklist screening is set to reject passwords on failure. This check calls the filter separately with an initial false, without the minimum-age verdict. A verified reset key already exempts the account from this refusal. The exemption does not bypass confirmed weak-password matches or other policy rules.
Parameters:
bool $is_compelled— The existing verdict for the minimum-age check, or an initialfalsefor the separate unreadable-weaklist check.?WP_User $user— The user object, ornullif not available.
Return: bool — true to exempt the change from the minimum password age rule and, in PRO, the unreadable-weaklist refusal for an existing account; false to grant no exemption through this filter.
add_filter(
'password_requirements__is_password_change_compelled',
function ( bool $is_compelled, ?WP_User $user ): bool {
// Users flagged for a mandatory reset by another system may always change their password.
if ( $user instanceof WP_User && get_user_meta( $user->ID, 'must_reset_password', true ) ) {
return true;
}
return $is_compelled;
},
10,
2
);
password_requirements__password_reset_form_link
Modify the URL where users are redirected when their password is non-compliant or expired. Third-party integrations (such as WooCommerce) use this filter to redirect to their own password reset pages.
Parameters:
string $url— The password reset form URL.WP_User $user— The user object.array $query_args— The query arguments used to construct the URL (includeskey,login,action,wp_lang).
Return: string — The modified URL.
add_filter(
'password_requirements__password_reset_form_link',
function ( string $url, WP_User $user, array $query_args ): string {
// Redirect to a custom password reset page.
return add_query_arg( $query_args, home_url( '/custom-reset/' ) );
},
10,
3
);
password_requirements__settings_fields_config
Extend or modify the settings fields configuration. This allows developers to add custom settings fields or modify validation rules.
Parameters:
array $config— The settings fields configuration array.
Return: array — The modified configuration array.
password_requirements__custom_password_weaklist (PRO)
Provide a custom list of weak passwords in addition to the built-in list of over 100,000 entries. Passwords on this list are rejected when the weaklist rule is enabled.
Parameters:
array $weaklist— An array of weak password strings. Default empty array.
Return: array — An array of password strings to reject.
add_filter(
'password_requirements__custom_password_weaklist',
function ( array $weaklist ): array {
// Add organization-specific weak passwords.
$weaklist[] = 'companyname123';
$weaklist[] = 'welcome2024';
return $weaklist;
}
);
password_requirements__custom_restricted_phrases
Add entries to the site-wide restricted words and phrases list at runtime. Contributions are additive: they are merged with the admin-managed list and cannot remove entries an administrator has saved.
Parameters:
array $phrases— Additional restricted phrases. Default empty array.
Return: array — The list of phrases to also block.
The active list is built once per password-policy object and reused for every check that object performs, so your callback runs once per policy rather than once per password check. Return the same phrases every time it is called: a callback that returns a different list on a later call within the same request has no effect, because the list built on the first call is the one every subsequent check uses.
add_filter(
'password_requirements__custom_restricted_phrases',
function ( array $phrases ): array {
$phrases[] = 'acme';
$phrases[] = 'acmecorp';
return $phrases;
}
);
password_requirements__vendor_default_usernames (PRO)
Add usernames that should be flagged as vendor defaults by Vendor-Default Account Detection, in addition to the built-in list. Matching is case-insensitive.
Parameters:
array $usernames— Additional usernames to flag. Default empty array.
Return: array — The list of usernames to also flag.
PHP Actions
password_requirements__settings_updated
Fires after the plugin settings are saved. Receives the new settings data, the previous settings data, and the settings object.
Parameters:
array $data— The updated settings data.array $old_data— The settings data before the update.Settings $settings— The settings object.
add_action(
'password_requirements__settings_updated',
function ( array $data, array $old_data ): void {
// Log settings changes or trigger other actions.
error_log( 'Password policy settings were updated.' );
},
10,
2
);
JavaScript Filters
These filters use the @wordpress/hooks package and run on the plugin’s settings screen (Settings → Login Security). Register a callback with addFilter() from a script that loads on that screen.
password_requirements__settings_page_tabs
Add, replace or remove tabs on the settings screen.
Parameters:
Array tabs— The tabs, in the order they are shown. Each tab is an object withname, which is also its address (#checksopens the tab namedchecks),title,component, the React element the tab shows, and optionallypaths, the settings paths whose unsaved changes put a dot after the tab’s name.Object settings— The settings as the screen holds them, unsaved changes included.Function setSettings— Updates the settings the screen holds.
Return: Array — The tabs to show.
The tab names are password-policy, checks and, in the free version, free-vs-pro. (PRO) PRO adds emails, accounts and license.
import { addFilter } from '@wordpress/hooks';
// Add a tab of your own to the Login Security settings screen.
addFilter( 'password_requirements__settings_page_tabs', 'my-plugin/settings-tab', ( tabs ) => [
...tabs,
{
name: 'my-tab',
title: 'My tab',
component: <MyTab />,
},
] );
password_requirements__settings_page_help_links
Change the documentation links that the Help panel lists under About this screen. A callback that adds a tab adds the links about it here.
Parameters:
Array links— The links about the open tab, each an object withtitleandurl.string currentTab— The name of the open tab.Function getDocsURL— Builds the address of a page of this documentation from its slug, such asgetDocsURL( 'age-rules' ).
Return: Array — The links to list.
import { addFilter } from '@wordpress/hooks';
// List the documentation about your tab in the Help panel while it is open.
addFilter( 'password_requirements__settings_page_help_links', 'my-plugin/help-links', ( links, currentTab ) =>
'my-tab' === currentTab ? [ { title: 'About my tab', url: 'https://example.com/docs/my-tab/' } ] : links
);
REST API Routes
The settings screen calls these routes under /wp-json/password-requirements/v1/. They are there for the screen, and the request and answer of each one can change between versions, so use the Abilities API for programmatic access instead. Every route except should-change-password is for users who can manage the plugin’s settings.
POST sample-password-check— Checks a sample password against a policy as it stands on the screen, unsaved changes included, for the Try the policy card. The sample is not stored or logged.POST new-password-on-save— Says whether saving the policies as they stand on the screen would send you to the password reset screen, for the notice under the header. It changes nothing.GET should-change-password— After a save, says whether your own password no longer meets the saved policy. If it does not, it signs you out and answers with the address of the password reset screen. Any logged-in user can call it.POST studio-plugins— Installs and activates another Teydea Studio plugin from the Teydea Studio plugins list in the Help panel. It also needs the permission to activate plugins, and to install them when the plugin is not installed yet.POST ordered-coverage(PRO) — Counts how many accounts each policy covers, in list order and with unsaved changes included, for the Who’s covered card.