Skip to main content

Hooks

Below are all hooks available in the TrustedLogin Client. These hooks can be used to customize the behavior of the Client.

Actions

trustedlogin/{namespace}/auth_screen

Renders the Grant Access/Revoke Access screen.

Note: TrustedLogin uses the 20 priority to print the auth screen.

trustedlogin/{namespace}/logging/log

ParameterTypeDescription
$messagestringMessage to log. Pre-processed to convert WP_Error and exceptions into strings.
$methodstringMethod that called the hook.
$levelstringA PSR-3 log level ('emergency', 'alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug')
$dataarrayAdditional error data.

trustedlogin/{namespace}/login/before

The support user login flow has begun. This is run before validation. If you want to a hook that runs only after successful login, use trustedlogin/{namespace}/login/after instead.

KeyTypeDescription
$user_identifierstringUnique identifier for support user.

trustedlogin/{namespace}/login/refused

The identifier fails security checks.

KeyTypeDescription
$user_identifierstringUnique identifier for support user.
$is_verifiedWP_ErrorThe error encountered when verifying the identifier.

Can be triggered with the following error codes:

  • brute_force_detected: Due to the current request triggering brute force checks, the site has entered lockdown mode.
  • in_lockdown: The site is currently in lockdown mode for a period of time.

trustedlogin/{namespace}/login/error

A support user fails to log in.

KeyTypeDescription
$user_identifierstringUnique identifier for support user.
$is_verifiedWP_ErrorThe error encountered when verifying the identifier.

Can be triggered with the following error codes:

  • user_not_found: There is no longer an existing support user (perhaps possibly because access has been revoked)
  • access_expired: Access has expired due to configuration expiration settings

trustedlogin/{namespace}/login/after

A support user has logged-in.

KeyTypeDescription
$user_identifierstringUnique identifier for support user.

trustedlogin/{namespace}/access/created

Access has been granted.

KeyTypeDescription
$urlstringThe site URL from where the access was granted, as returned by get_site_url()
$actionstringThe type of trigger: created, extended, or revoked
$refstring,nullA sanitized reference ID, if passed. Otherwise, null.
$debug_dataarray(Not always set) An array of site data generated by Client::get_debug_data(). Similar to \WP_Debug_Data::debug_data() output with Markdown formatting improvements applied. Added in 1.4.0.

trustedlogin/{namespace}/access/extended

Existing access has been extended.

KeyTypeDescription
$urlstringThe site URL from where the webhook was triggered, as returned by get_site_url()
$actionstringThe type of trigger: created, extended, or revoked
$refstring,nullA sanitized reference ID, if passed. Otherwise, null.

trustedlogin/{namespace}/access/revoked

Access has been revoked.

KeyTypeDescription
$urlstringThe site URL from where the webhook was triggered, as returned by get_site_url()
$actionstringThe type of trigger: created, extended, or revoked

trustedlogin/{namespace}/logged_in

A support user has logged-in to a site.

KeyTypeDescription
$urlstringThe site URL from where the webhook was triggered, as returned by get_site_url()
$actionstringSet to logged_in

Filters

trustedlogin/{namespace}/admin/menu/menu_slug

Override the menu slug used for the Grant Support Access screen.

KeyTypeDefaultDescription
$menu_slugstring'grant-{namespace}-access'Value passed to add_menu_page() as the $menu_slug parameter.

trustedlogin/{namespace}/template/auth

Override the structure of the auth form HTML.

KeyTypeDefaultDescription
$auth_screen_templatestringHTML with placeholders (see below)The structure for the auth form HTML, with placeholders.

trustedlogin/{namespace}/template/auth/display_reference

Toggles whether the reference ID, if set, is shown in the auth form. Since Version 1.3.

KeyTypeDefaultDescription
$display_referencebooltrueWhether to display the reference ID on the auth screen.
$is_login_screenboolWhether the auth form is being displayed on the login screen. Set by Admin::login_screen().
$refstringThe reference ID.

trustedlogin/{namespace}/template/auth/terms_of_service/anchor

KeyTypeDefaultDescription
$anchorstringTerms of ServiceThe anchor text of the Terms of Service link.

Override the footer links shown below the auth form.

KeyTypeDefaultDescription
$footer_linksarray[ 'Learn About TrustedLogin' => 'https://www.trustedlogin.com/about/easy-and-safe/', 'Visit {vendor/title} support' => {vendor/support_url} ]Array of links to show in auth footer (Key is anchor text; Value is URL)

trustedlogin/{namespace}/support_role

Change the name (slug) of the role created for the support user. Will be sanitized using sanitize_title_with_dashes().

KeyTypeDefaultDescription
$role_namestring'{namespace}-support'The name of the role, which is more like the slug.
$configTrustedLogin\ConfigCurrent TrustedLogin configuration object

trustedlogin/{namespace}/support_role/display_name

Change the display name of the role created for support users. This will be displayed in the filter menu above the Users table in the Dashboard, as well as in a list of site roles.

KeyTypeDefaultDescription
$display_namestring'%s Support'A string prepared for localization where %s is replaced by the vendor/title configuration setting (for example, "Acme Support").
$configTrustedLogin\ConfigCurrent TrustedLogin configuration object

trustedlogin/{namespace}/license_key

Modify the license key assigned to the current user. This should ideally be defined using the auth/license_key configuration setting.

KeyTypeDefaultDescription
$license_keystring, nullnullGet the license key for the current user.

trustedlogin/{namespace}/support_url/query_args

If TrustedLogin fails to grant access to users, a button appears that will link directly to the vendor/support_url configuration setting.

This filter exists to modify parameters added to that URL.

KeyTypeDefaultDescription
$query_argsarraySee default array keys below

$query_args array value

KeyTypeDefaultDescription
query_args/messagestringCould not create TrustedLogin access.What error message should be appended to the support URL.
query_args/refstring, nullnullA sanitized reference ID, if passed. Otherwise, null.

trustedlogin/{namespace}/envelope/meta

Adds custom metadata to be synced via TrustedLogin and stored in the Envelope. Limited to 1MB.

warning

Metadata is transferred and stored in plain text. Do not add any unencrypted sensitive data or identifiable information!

KeyTypeDefault
$metadataarray[] (empty array)
$configTrustedLogin\ConfigCurrent TrustedLogin configuration object

trustedlogin/{namespace}/logging/enabled

Toggles whether logging is enabled. It can be helpful to have a filter to override logging outside the configuration array!

KeyTypeDefaultDescription
$is_enabledboolfalseWhether debug logging is enabled in TrustedLogin Client

trustedlogin/{namespace}/vendor/public_key/website

warning

Only use this filter if the vendor/website setting is not the same as the website where the TrustedLogin Connector plugin is running.

If the vendor/website setting and the website running the TrustedLogin Connector plugin are not the same, use this filter.

For example, if the vendor/website setting is https://www.parentcompany.com but TrustedLogin is running on the https://child.parentcompany.com, you would use this filter to point to https://child.parentcompany.com.

KeyTypeDefaultDescription
$public_key_websitestringThe vendor/website configuration settingThe root URL of the website where the Connector plugin is running.

trustedlogin/{namespace}/vendor/public_key/endpoint

warning

Only use this filter if the REST API endpoint has changed on the Vendor website.

Override the path to TrustedLogin's WordPress REST API endpoint. If there have been customizations to the REST API endpoint structure on the Vendor, the path may need to be modified.

For example, if the rest_url_prefix filter is used to change the REST API URL from /wp-json/, you will need to update the endpoint.

KeyTypeDefaultDescription
$public_key_endpointstringwp-json/trustedlogin/v1/public_keyThe vendor's signature key REST API endpoint, which will be added to the vendor/website configuration setting.

🛑 Advanced Internal Use Only

warning

These filters should not be used in production code. They are included here as helpful developer reference only, and they may change.

🚫 You really don't need these filters! 🚫

Using these filters incorrectly may break everything and make a site insecure. They are used for advanced use cases like automated end-to-end testing. They're only included here so our documentation is complete. Only use if you know what you're doing!

trustedlogin/{namespace}/meets_ssl_requirement

Logins will not be synced with TrustedLogin if the site doesn't have proper SSL support. Sometimes, when testing, it's helpful to have a filter to override this behavior.

KeyTypeDefaultDescription
$returnboolis_ssl() && $config['require_ssl']Does this site meet the SSL requirement?

trustedlogin/{namespace}/api_url

Modifies the endpoint URL for the TrustedLogin service. This allows pointing requests to test servers.

KeyTypeDefaultDescription
$base_urlstringhttps://app.trustedlogin.com/api/v1/URL of TrustedLogin API
warning

These filters should not be used in production code. They are included here as helpful developer reference only, and they may change.

trustedlogin/{namespace}/vendor_public_key

Override the public key functions. Encryption will break if this is changed.

KeyTypeDefault
$remote_keystringVaries
$configTrustedLogin\ConfigCurrent TrustedLogin configuration object
warning

These filters should not be used in production code. They are included here as helpful developer reference only, and they may change.

trustedlogin/{namespace}/options/endpoint

Modify the namespaced setting name for storing part of the auto-login endpoint. The endpoint value must be treated carefully. It is one of the two parts required to log in.

KeyTypeDefault
$option_namestringtl_{namespace}_endpoint
$configTrustedLogin\ConfigCurrent TrustedLogin configuration object