Skip to content

Developer Integration

Job van Koeveringe edited this page Nov 2, 2026 · 3 revisions

Developer Integration

This page documents the public plugin actions intended for custom WordPress integrations. Build integrations on these actions rather than editing plugin files or relying on private classes, options, transient names, or user metadata implementation details.

Available actions

Action When it fires Parameters
scouting_oidc_user_register After a local WordPress user is created through a verified OIDC login, before the plugin updates its OIDC metadata. int $user_id, string $sol_id, string $email
scouting_oidc_wp_login After the plugin sets the current user and authentication cookie and the core wp_login callbacks return. See the redirect limitation below. string $user_login, WP_User $user

The plugin also fires WordPress core's wp_login action after a verified OIDC login. Prefer the plugin-specific action when custom behavior must run only for Scouting OIDC logins.

In 2.7.0, configured redirects run inside core wp_login and can terminate the request before scouting_oidc_wp_login is reached. This includes the default front-page destination and shortcode redirect_back flows. Do not rely on the plugin-specific action for mandatory access enforcement or work that must run on every login. The built-in role mapping runs before these login actions.

Register a new OIDC user

Use this action to initialize site-specific data for a newly created, verified OIDC user.

add_action(
	'scouting_oidc_user_register',
	function ( int $user_id, string $sol_id, string $email ): void {
		// Initialize only application-specific user data here.
	},
	10,
	3
);

Do not use this hook to overwrite the plugin's identity-binding metadata. The plugin completes that metadata update immediately after this action fires.

Respond to a verified OIDC login

Use this action for behavior that must occur only after an OIDC user is fully authenticated in WordPress.

add_action(
	'scouting_oidc_wp_login',
	function ( string $user_login, WP_User $user ): void {
		// Run site-specific post-login work for this verified OIDC user.
	},
	10,
	2
);

Use the fully qualified \WP_User type in namespaced code, or import it with a use WP_User; declaration.

Role assignment guidance

Since 2.7.0, the plugin maps synchronized SOL assignments to all matching WordPress roles before setting the authentication cookie and firing login actions. Prefer the built-in SOL role mapping for this use case rather than duplicating it in an integration.

The scouting_oidc_user_register action runs before role synchronization and mapping, so it must not assume either has completed. New OIDC accounts are created without an initial role; mapping or the unmatched-user default is assigned afterward. Custom role reconciliation after login needs a trustworthy entitlement source and must avoid managing the same roles the plugin tracks. A role independently added by an integration is not automatically revoked by changing the mapped roles.

Avoid role changes based only on an email address, display name, or URL request parameter. Apply least privilege, log administrative role changes appropriately, and ensure a failure in optional integration code cannot bypass the plugin's OIDC validation or leave an unintended role assignment behind.

Compatibility boundaries

The plugin's current public extension points are the actions listed above. The following are implementation details and should not be treated as stable APIs:

  • scouting_oidc_* option names.
  • OIDC session-cookie and transient-key formats.
  • Private classes, methods, and login-flow internals.
  • Database table schemas other than through supported administrator interfaces.

If a needed integration requires a new hook or filter, open an issue with the use case, expected data, lifecycle timing, and security considerations.

Testing an integration

  1. Use a non-production WordPress environment and an authorized test connection.
  2. Test new-account creation and repeat login separately.
  3. Test a normal WordPress login to verify the integration is limited to OIDC when intended.
  4. Test a failed provider login to ensure the extension does not run early.
  5. Test logout, account binding errors, and duplicate-email behavior where relevant.
  6. Do not log or expose Client Secrets, authorization codes, access tokens, ID tokens, or session cookies.

Clone this wiki locally