Skip to content

docs: document login_redirect filter for post-2FA redirect (#278)#849

Merged
masteradhoc merged 2 commits intoWordPress:masterfrom
masteradhoc:readme-documentation-redirect
Mar 26, 2026
Merged

docs: document login_redirect filter for post-2FA redirect (#278)#849
masteradhoc merged 2 commits intoWordPress:masterfrom
masteradhoc:readme-documentation-redirect

Conversation

@masteradhoc
Copy link
Copy Markdown
Collaborator

Fixes #278

What?

Adds a short documentation entry to readme.txt explaining how to redirect users after the two-factor challenge completes.

Why?

There was no documentation on how to control the post-login destination when 2FA is enabled.

How?

Adds a new = Redirect After the Two-Factor Challenge = entry to the Actions & Filters section in readme.txt with a working login_redirect filter example.

Testing Instructions

  1. Install the plugin and enable 2FA for a user.
  2. Add the following to functions.php:
add_filter( 'login_redirect', function( $redirect_to, $requested_redirect_to, $user ) {
    return home_url( '/dashboard/' );
}, 10, 3 );
  1. Log in with that user and complete the 2FA challenge.
  2. Confirm the user lands on /dashboard/.

Screenshots or screencast

N/A

Changelog Entry

Added - Document the login_redirect filter for controlling redirect destination after the two-factor challenge.

@github-actions
Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core SVN

If you're a Core Committer, use this list when committing to wordpress-develop in SVN:

Props: masteradhoc, kasparsd.

GitHub Merge commits

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: masteradhoc <masteradhoc@git.wordpress.org>
Co-authored-by: kasparsd <kasparsd@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@masteradhoc masteradhoc self-assigned this Mar 25, 2026
@masteradhoc masteradhoc added this to the 0.16.0 milestone Mar 25, 2026
readme.txt Outdated

== Redirect After the Two-Factor Challenge ==

To redirect users to a specific URL after completing the two-factor challenge, use the `login_redirect` filter:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we call out that this is a core WP filter and the plugin doesn't require any special treatment of the login redirect?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kasparsd good point, done :) what do you think?

@masteradhoc masteradhoc merged commit 2ace85b into WordPress:master Mar 26, 2026
30 checks passed
@masteradhoc masteradhoc deleted the readme-documentation-redirect branch March 26, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document redirect_url input parameter for custom login forms

2 participants