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

Open Beginner friendly
#963 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php, wordpress

Research direction

Start with onLogin() and onExchangeFailed() around the referenced redirect calls, then compare them with onLogout(), which already passes the subsite-aware URL. Update the four login and exchange redirect locations so a Multisite subdirectory login stays on the current site, and verify the reproduction redirects to /subsite-a/ rather than the network root.

Written by the indexing model from the issue text.

Description

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

Dominant language
PHP
Stars
182
Forks
103
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from auth0/wordpress

All issues in auth0/wordpress

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.