Skip to content

Latest commit

 

History

History
449 lines (294 loc) · 14.8 KB

File metadata and controls

449 lines (294 loc) · 14.8 KB

Filter Hooks

Table of Contents

GraphQL Type Registration

graphql_login_registered_{type}_classes

Filters the list of classes that are registered as GraphQL Types.

Possible type values are connection, enum, field, input, interface, mutation and object.

apply_filters( 'graphql_login_registered_connection_classes', $classes );
apply_filters( 'graphql_login_registered_enum_classes', $classes );
apply_filters( 'graphql_login_registered_field_classes', $classes );
apply_filters( 'graphql_login_registered_input_classes', $classes );
apply_filters( 'graphql_login_registered_interface_classes', $classes );
apply_filters( 'graphql_login_registered_mutation_classes', $classes );
apply_filters( 'graphql_login_registered_object_classes', $classes );

Parameters

  • $classes (array) : The list of PHP classes that are registered as GraphQL Types. These classes must extend the WPGraphQL\Login\Vendor\AxeWP\GraphQL\Interfaces\GraphQLType interface.

Authentication

graphql_login_authenticated_user_data

Filters the user data returned from the Authentication provider.

apply_filters( 'graphql_login_authenticated_user_data', $user_data, $slug, $input, $settings, $provider_config, $client );

Parameters

  • $user_data (array|\WP_User|\WP_Error|false) : The user data returned from the Authentication provider.
  • $slug (string) : The provider slug.
  • $input (array) : The mutation input data.
  • $settings (array) : The client settings.
  • $provider_config (\WPGraphQL\Login\Auth\ProviderConfig\ProviderConfig) : The instance of the ProviderConfig.
  • $client (WPGraphQL\Login\Auth\Client) : The authentication client.

graphql_login_pre_get_user_from_data

Shortcircuits the user matching logic, allowing you to provide your own logic for matching the user from the provider user data. If null is returned, the default matching logic will be used.

apply_filters( 'graphql_login_pre_get_user_from_data', null, $user_data, $slug, $settings, $provider_config, $client );

Parameters

  • $user (WP_User|null) : The user that was matched from the provider user data. If null, the default matching logic will be used.
  • $user_data (array|\WP_User|\WP_Error|false) : The user data returned from the Authentication provider.
  • $slug (string) : The provider slug.
  • $settings (array) : The client settings.
  • $provider_config (\WPGraphQL\Login\Auth\ProviderConfig\ProviderConfig) : The instance of the ProviderConfig.
  • $client (WPGraphQL\Login\Auth\Client) : The authentication client.

graphql_login_create_user_data

Filters the user data mapped from the Authentication provider before creating the user. Useful for mapping custom fields from the Authentication provider to the WP_User.

apply_filters( 'graphql_login_create_user_data', $user_data, $client );

Parameters

  • $user_data (array) : The user data returned from the Authentication provider.
  • $client (WPGraphQL\Login\Auth\Client) : The authentication client.

graphql_login_payload

Filters the Login mutation payload before returning.

apply_filters( 'graphql_login_payload', $payload, $user, $user_data, $client );

Parameters

  • $payload (array) : The Login mutation payload.
  • $user (WP_User) : The authenticated user.
  • $user_data (array) : The user data returned from the authentication provider.
  • $client (WPGraphQL\Login\Auth\Client) : The authentication client.

Secrets & Tokens

graphql_login_jwt_secret_key

Filter the secret key used to sign the JWT auth and refresh tokens.

apply_filters( 'graphql_login_jwt_secret_key', $secret );

Parameters

  • $secret (string) : The secret key.

graphql_login_refresh_token_validity

Filters the duration for which a Refresh Token should be considered valid.

apply_filters( 'graphql_login_refresh_token_validity', $validity );

Parameters

  • $validity (int) : The validity in seconds. Defaults to 1 year.

graphql_login_refresh_token_expiration_timestamp

Filters the Refresh Token expiration timestamp for all users.

apply_filters( 'graphql_login_refresh_token_expiration_timestamp', $timestamp );

Parameters

  • $timestamp (int) : The expiration timestamp.

graphql_login_user_secret

Filter the user secret before returning it, allowing for individual systems to override what's returned.

apply_filters( 'graphql_login_user_secret', $secret, $user_id );

Parameters

  • $secret (string|WP_Error) : The user secret.
  • $user_id (int) : The user ID.

graphql_login_iss_allowed_domains

Filter the allowed domains for the token. This is useful if you want to make your token valid over several domains.

apply_filters( 'graphql_login_iss_allowed_domains', $allowed_domains );

Parameters

  • $allowed_domains (string[]) : An array of allowed domains.

graphql_login_edit_jwt_capability

Filter the capability that is tied to editing/viewing user OAuth info.

apply_filters( 'graphql_login_edit_jwt_capability', $capability );

Parameters

  • $capability (string) : The user capability. Defaults to 'edit_users'.

graphql_login_token_not_before_timestamp

Determines the "not before" value for the user's auth and refresh tokens.

apply_filters( 'graphql_login_token_not_before_timestamp', $issued, $user );

Parameters

  • $issued (int) : The timestamp of the authentication used in the token`.
  • $user (WP_User) : The authenticated user.

graphql_login_token_expiration_timestamp

Determines the "not before" value for the user's auth and refresh tokens.

apply_filters( 'graphql_login_token_expiration_timestamp', $issued, $user );

Parameters

  • $issued (int) : The timestamp of the authentication used in the token`.
  • $user (WP_User) : The authenticated user.

graphql_login_token_before_sign

Filters the token before it is signed, allowing for individual systems to configure the token as needed.

apply_filters( 'graphql_login_token_before_sign', $token, $user );

Parameters

  • $token (array) : The token array that will be encoded.
  • $user (WP_User) : The authenticated user.

graphql_login_signed_token

Filter the token before returning it, allowing for individual systems to override what's returned. For example, if the user should not be granted a token for whatever reason, a filter could have the token return null.

apply_filters( 'graphql_login_signed_token', $token, $user_id );

Parameters

  • $token (string) : The signed JWT token that will be returned.
  • $user_id (int) : The ID of the user the JWT is associated with.

graphql_login_token_validity

Filter the validity length for the token. Defaults to 300 seconds.

apply_filters( 'graphql_login_token_validity', $validity );

Parameters

  • $validity (int) : The validity length (in seconds)

Authorization Headers

graphql_login_auth_header

Filters the Authorization header before it is used to authenticate the user's HTTP request.

apply_filters( 'graphql_login_auth_header', $auth_header );

Parameters

  • $auth_header (string) : The header used to authenticate a user's HTTP request.

graphql_login_refresh_header

Filters the Refresh Authorization header before it is used to authenticate the user's HTTP request.

apply_filters( 'graphql_login_refresh_header', $refresh_header );

Parameters

  • $refresh_header (string) : The refresh header.

Client & Provider Configuration

graphql_login_registered_provider_configs

Filters the registered provider configurations. Useful for removing a built-in provider, or for adding a custom one.

apply_filters( 'graphql_login_registered_provider_configs', $provider_configs);

Parameters

  • $provider_configs (array) : The registered ProviderConfig classes, keyed to their slug.

graphql_login_provider_config_instances

Filters the list of enabled ProviderConfig instances.

apply_filters( `graphql_login_provider_config_instances', $provider_configs );

Parameters

  • $provider_configs (WPGQL\Login\Auth\ProviderConfig\ProviderConfig[]) : The list of enabled ProviderConfig instances.

graphql_login_client_options_fields

Filters the GraphQL fields for the provider's Client Options.

apply_filters( 'graphql_login_client_options_fields', $fields, $slug );
apply_filters( 'graphql_login_{$slug}_client_options_fields', $fields );

Parameters

  • $fields (array) : An array of WPGraphQL field $configs.
  • $slug (string) : The Authentication provider slug.

graphql_login_client_options_schema

Filters the WP REST schema for the provider's Client Options settings. Useful for modifying Client Options displayed in the admin.

apply_filters( 'graphql_login_client_options_schema', $settings, $slug );
apply_filters( 'graphql_login_{$slug}_client_options_fields', $settings );

Parameters

  • $settings (array) : The WP REST schema config, with the addition of the 'help' and 'required' key/values used when displaying the settings in the Admin.
  • $slug (string) : The Authentication provider slug.

graphql_login_setting

Filters the value of a setting.

apply_filters( 'graphql_login_setting', $value, $option_name, $default );

Parameters

  • $value (mixed) : The value of the setting.
  • $option_name (string) : The name of the setting. In the database, this is prefixed with wpgraphql_login_settings
  • $default (mixed) : The default value of the setting.

graphql_login_access_control_settings

Filters the settings for a provider.

apply_filters( 'graphql_login_access_control_settings', $settings, $slug );

Parameters

  • $settings (array) : The access control settings.
  • $default (string) : The default value if none is set.

graphql_login_provider_settings

Filters the settings for a provider.

apply_filters( 'graphql_login_provider_settings', $settings, $slug );

Parameters

  • $settings (array) : The settings for the provider.
  • $slug (string) : The provider slug.

graphql_login_login_options_fields

Filters the GraphQL fields for the provider's Login Options.

apply_filters( 'graphql_login_login_options_fields', $fields, $slug );
apply_filters( 'graphql_login_{$slug}_login_options_fields', $fields );

Parameters

  • $fields (array) : An array of WPGraphQL field $configs.
  • $slug (string) : The Authentication provider slug.

graphql_login_login_options_schema

Filters the WP REST schema for the provider's Client Options settings. Useful for modifying Client Options displayed in the admin.

apply_filters( 'graphql_login_login_options_schema', $settings, $slug );
apply_filters( 'graphql_login_{$slug}_login_options_fields', $settings );

Parameters

  • $settings (array) : The WP REST schema config, with the addition of the 'help' and 'required' key/values used when displaying the settings in the Admin.
  • $slug (string) : The Authentication provider slug.

graphql_login_client_options

Filters the options used to configure the OAuth2 provider instance within the ProviderConfig.

apply_filters( 'graphql_login_client_options', $options, $slug );

Parameters

  • $options (array) : The provider options stored in the database.
  • $slug (string) : The authentication provider slug.

graphql_login_user_types

Filters the GraphQL User types which should have the auth: AuthenticationData field added to them.

apply_filters( 'graphql_login_user_types', $type_names);

Parameters

  • $type_names (string[]) : The names of the GraphQL 'user' types. Defaults to 'User'

Reference