Skip to content

wp_redirect('/') after login breaks WordPress Multisite subdirectory installs #963

Description

@hanifn

Checklist

  • I have looked into the Readme and the documentation, and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

Several code paths hardcode wp_redirect('/') instead of resolving the current site's URL. On a Multisite subdirectory install, an absolute / always resolves to the network's root site, not the subsite the user is actually logging into. onLogout() gets this right (passes get_site_url(), which is subsite-aware) but the login/exchange paths don't.

Reproduction

  1. Set up WordPress Multisite in subdirectory mode with at least one non-root subsite.
  2. Configure and activate the plugin network-wide.
  3. Log in on example.com/subsite-a/wp-login.php.
  4. Observe the redirect lands on example.com/ (network root) instead of example.com/subsite-a/.

Additional context

// onLogin() success, ~539 / error, ~546 / already-authenticated, ~551
wp_redirect('/');
// onExchangeFailed(), ~562
wp_redirect('/');

Related: #935, closed as stale without a confirmed root cause. Suggested fix: use admin_url() or get_site_url() in all four locations, matching onLogout().

wp-auth0 version

5.6.1

WordPress version

7.1

PHP version

8.4

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions