[wp-trac] [WordPress Trac] #64785: Add filter for redirect_to URL in get_the_password_form()
WordPress Trac
noreply at wordpress.org
Tue Mar 3 10:45:00 UTC 2026
#64785: Add filter for redirect_to URL in get_the_password_form()
-------------------------------+-----------------------------
Reporter: regnalf | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: 6.9.1
Severity: normal | Keywords:
Focuses: |
-------------------------------+-----------------------------
**Description of the Problem:**
Currently, get_the_password_form() hardcodes the redirect_to hidden input
value directly to get_permalink( $post->ID ). While there is a filter for
the entire form HTML (the_password_form), changing only the redirect URL
requires brittle string manipulation (like str_replace or regex) on the
rendered HTML block.
**Use Case:**
When building custom features like "Public Preview Links" for draft or
unpublished posts, or when working with custom routing/headless setups,
the standard permalink is often not the correct URL to redirect the user
back to after a successful password entry.
**Proposed Solution:**
Introduce a dedicated filter (e.g., the_password_form_redirect_url or
password_form_redirect_to) to easily modify the redirect destination
without parsing HTML.
I will link a GitHub Pull Request with the proposed code and a unit test
shortly.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64785>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list