VOOZH about

URL: https://deepwiki.com/auth0/wordpress/4.5-extending-the-plugin

⇱ Extending the Plugin | auth0/wordpress | DeepWiki


Loading...
Menu

Extending the Plugin

Purpose and Scope

This page documents the supported approach for extending the Auth0 WordPress plugin with custom functionality. It explains how to access the underlying Auth0-PHP SDK through the plugin's public API to integrate Auth0 features into custom WordPress development.

For information about the plugin's configuration options, see Configuration Options. For details about the internal architecture, see System Overview.

Important: This plugin is not designed to be extended by modifying or subclassing its internal components. The plugin's classes and methods are considered internal implementation details that may change without notice. The only supported extension mechanism is accessing the Auth0-PHP SDK through the wpAuth0() helper function.


Extension Architecture Overview

The plugin provides a single stable extension point: the wpAuth0() helper function. This function returns the plugin singleton, which provides access to a fully configured instance of the Auth0-PHP SDK.

Extension Point Architecture


Sources: README.md169-184 wpAuth0.php72-89


The wpAuth0() Helper Function

The wpAuth0() function is the sole public entry point for accessing the plugin's functionality. It implements the singleton pattern to provide access to the plugin instance.

Function Signature

The function is defined in wpAuth0.php79-89 with the following signature:


Basic Usage


The function returns an instance of Auth0\WordPress\Plugin. On first call, it initializes the plugin with configuration from the WordPress database. Subsequent calls return the same instance.

Function Behavior

Singleton Pattern Implementation


Sources: wpAuth0.php79-89

Optional Parameters

The function accepts optional parameters for testing or advanced use cases:

ParameterTypePurpose
$plugin?PluginOverride the singleton with a specific Plugin instance
$sdk?SdkProvide a custom Auth0 SDK instance
$configuration?ConfigurationProvide a custom SDK configuration

Note: In normal usage, all parameters should be omitted. These parameters are primarily used for testing.

Sources: wpAuth0.php79-89


Accessing the Auth0-PHP SDK

The primary purpose of the wpAuth0() helper is to provide access to a configured instance of the Auth0-PHP SDK through the getSdk() method.

Basic SDK Access


This returns an instance of Auth0\SDK\Auth0 that is fully configured with:

  • Domain from plugin settings
  • Client ID and Client Secret
  • Callback URLs and redirect URIs
  • Session management configuration
  • Token storage and refresh settings
  • Organization settings (if configured)
  • Custom domain settings (if configured)

SDK Access Pattern

Retrieving the Configured SDK


Sources: README.md175-182 wpAuth0.php79-89

Configuration Access

You can also access the SDK configuration directly if needed:


This returns an instance of Auth0\SDK\Configuration\SdkConfiguration containing all configuration values loaded from the WordPress database options (auth0_client, auth0_authentication, auth0_cookies, etc.).

Sources: README.md169-184


Important Limitations

Do Not Extend Plugin Classes

Critical: The plugin's internal classes and methods are not stable APIs and are subject to change without notice. Do not:

  • Extend plugin classes (e.g., Auth0\WordPress\Actions\Authentication)
  • Instantiate plugin classes directly
  • Call methods on plugin internal objects
  • Access plugin protected or private properties
  • Hook into plugin internal actions or filters (unless documented)

Unsupported Extension Patterns


Rationale: The plugin's internal architecture may change significantly between versions. Code that depends on internal implementation details will break during updates.

Sources: README.md14-15 README.md173-174

Version Compatibility

The plugin does not guarantee backwards compatibility for internal APIs. Only the following are considered stable:

  • The wpAuth0() helper function signature and return type
  • The Plugin::getSdk() method signature and return type
  • The Plugin::getConfiguration() method signature and return type

All other plugin classes, methods, and interfaces may change without warning.

Sources: README.md14-15


SDK Capabilities

The Auth0-PHP SDK provides comprehensive access to Auth0's features. Through wpAuth0()->getSdk(), you gain access to:

Available API Categories

SDK Feature Domains


Common API Operations

CategoryMethodPurpose
Authenticationlogin()Generate Universal Login URL
exchange()Exchange authorization code for tokens
decode()Validate and decode ID tokens
renew()Refresh access tokens
User Managementusers()Access Users endpoint
usersByEmail()Search users by email
SessiongetUser()Retrieve authenticated user data
getAccessToken()Get current access token
getIdToken()Get current ID token
clear()Clear session data
Organizationsorganizations()Access Organizations endpoint

Sources: README.md169-184


Common Extension Patterns

Example: Custom User Metadata Update

Update Auth0 user metadata from WordPress:


Example: Check User Roles in Auth0

Query Auth0 roles for additional authorization:


Example: Custom Organization Validation

Validate organization membership before granting access:


Extension Pattern Flow


Sources: README.md169-184


SDK Configuration Details

The SDK instance returned by wpAuth0()->getSdk() is preconfigured with all settings from the plugin's configuration pages. This includes:

Configuration Sources

How Plugin Configuration Flows to SDK


Configured Settings

The SDK instance includes configuration for:

Setting CategoryConfiguration SourceSDK Usage
Domainauth0_client['domain']API endpoint base URL
Client Credentialsauth0_client['id'], auth0_client['secret']API authentication
Callback URLsauth0_authentication['callback_url']OAuth flow redirects
Session Managementauth0_sessions, auth0_cookiesToken storage and refresh
Organizationsauth0_client_advanced['organizations']Organization filtering
Custom Domainauth0_client_advanced['custom_domain']Custom Auth0 domain
Token Settingsauth0_authentication['token_*']Token validation and refresh

Note: Changing plugin configuration through the WordPress admin UI will not affect an already-instantiated SDK instance until the next request, as the plugin singleton is created once per request.

Sources: README.md169-184


Support and Documentation

Auth0-PHP SDK Resources

Since you're working with the Auth0-PHP SDK through this extension point, refer to the SDK's documentation:

Getting Help

Issue TypeResource
SDK usage questionsAuth0 Community forum
SDK bugs or featuresAuth0-PHP SDK repository issues
Plugin configurationThis plugin's GitHub issues
Plugin bugsThis plugin's GitHub issues

Important Notes

  1. Questions about extending the plugin using the SDK should be directed to the Auth0 Community, as they involve SDK usage rather than plugin-specific functionality.

  2. The plugin maintainers cannot provide support for custom code that uses the SDK, as this falls outside the plugin's scope.

  3. Security vulnerabilities should be reported through Auth0's Responsible Disclosure Program, not through public issue trackers.

Sources: README.md183-216


Summary

The Auth0 WordPress plugin provides a single, stable extension point for custom development:

  1. Use wpAuth0() to access the plugin singleton
  2. Call getSdk() to retrieve a configured Auth0-PHP SDK instance
  3. Use SDK methods to integrate Auth0 features into your custom code
  4. Do not extend plugin internal classes or methods
  5. Refer to SDK documentation for detailed API usage

This approach ensures your custom code remains compatible across plugin updates while providing full access to Auth0's authentication and management capabilities.

Sources: README.md169-184 wpAuth0.php72-89