How to use the universal login (hosted page) with wordpress?

Hi I don’t want to use the embedded login as we are having issues with cookies cross domains. What’s the best method to use the Universal Login instead of the embedded login?

Hi @markjones333 … it’s a bit of an undocumented feature (for now, we’ll label it better in an upcoming release) but if you go to wp-admin > Auth0 > Settings > Advanced tab, turn on “Auto-Login,” and leave “Auto Login Method” blank, that will redirect to the hosted login page.

1 Like

Thanks. Tried this out with these settings:

It still shows embedded. Anything more i need to do ?

Just to make sure … did you save the settings?

And you’re saying that it’s still showing embedded at wp-login.php? Widgets and shortcodes will still use embedded but the login page should redirect. Try clearing your browser cache.

How do I make this work with woocommerce?

wp-login.php works, but /my-account/ still shows an embedded form.

@JanErikFoss - That page can be anything and, with widgets/shortcodes, there’s no great way to always make sure to redirect login pages on a site. For WooCommerce, or any plugin that creates it’s own login route, you’ll need to check for authentication and redirect if needed, likely in the template_redirect hook. This method will generate the URL you’ll need to use:

https://github.com/auth0/wp-auth0/blob/master/lib/WP_Auth0_LoginManager.php#L719

And example of this working in a custom page template is here:

Thank you. This is what I came up with

add_action( 'template_redirect', 'bikefinder_template_redirect');
function bikefinder_template_redirect() {

    // Page is my-account and user is not logged in
    if (is_page('my-account') && !is_user_logged_in()) {

        // Redirect
        header('Location: /wp-login.php');
        exit; 
    }
}
1 Like

That should work fine, though I would recommend wp_safe_redirect() for this use. Here is a more general solution I just put together:

The is_page() works fine if that’s the slug of your My Account page but you can also get the page ID and use that. This also redirects back to the My Account page on authentication

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.