Login by Auth0 Shortcode

Below, you’ll find a detailed guide on how to add the Login by Auth0 Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Login by Auth0 Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Login by Auth0 Plugin and the shortcodes it provides:

Plugin Icon
Login by Auth0

"Login by Auth0 is a secure and easy-to-integrate WordPress plugin that simplifies user authentication. Its robust features streamline signups, logins, and identity verification, providing a seamless UX."

★★★✩✩ (15) Active Installs: 5000+ Tested with: 6.1.4 PHP Version: 7.4
Included Shortcodes:
  • [auth0]

Login by Auth0 [auth0] Shortcode

The Auth0 shortcode is a powerful tool in WordPress. It facilitates user authentication by rendering the Auth0 login form. Upon calling, it checks if any attributes are passed. If none, an empty array is created. It then verifies if a ‘redirect_to’ attribute exists. If absent, it defaults to the current page URL. The ob_start() function initiates output buffering, capturing the output rather than sending it to the browser. The \WP_Auth0_Lock::render function then displays the Auth0 login form, with the specified attributes. The ob_get_clean() function ends output buffering and returns the contents.

Shortcode: [auth0]


Here is a list of all possible auth0 shortcode parameters and attributes:

  • redirect_to – defines the URL where users are redirected after authentication

Examples and Usage

Basic Example – Use the Auth0 shortcode to initiate the login process. This will redirect users to the same page after successful authentication.

[auth0 /]

Advanced Examples

Use the Auth0 shortcode with a specified redirect URL. After successful authentication, users will be redirected to the specified page. Replace ‘your-redirect-url’ with the actual URL where you want to redirect your users.

[auth0 redirect_to='your-redirect-url' /]

Use the Auth0 shortcode with multiple attributes. This example includes a custom redirect URL, and additional parameters for the Auth0 Lock. Replace ‘your-redirect-url’, ‘custom-connection’ and ‘custom-language’ with the actual values.

[auth0 redirect_to='your-redirect-url' connection='custom-connection' language='custom-language' /]

Please note that ‘connection’ and ‘language’ are just example attributes. You should replace them with the actual parameters supported by the Auth0 Lock.

PHP Function Code

In case you have difficulties debugging what causing issues with [auth0] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'auth0', 'wp_auth0_shortcode' );

Shortcode PHP function:

function wp_auth0_shortcode( $atts ) {
	if ( empty( $atts ) ) {
		$atts = [];

	if ( empty( $atts['redirect_to'] ) && ! empty( $_SERVER['REQUEST_URI'] ) ) {
		$atts['redirect_to'] = home_url( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) );

	\WP_Auth0_Lock::render( false, $atts );
	return ob_get_clean();

Code file location:



Now that you’ve learned how to embed the Login by Auth0 Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.


Leave a Reply

Your email address will not be published. Required fields are marked *