Make WordPress Core

Changeset 64348


Ignore:
Timestamp:
10/14/2026 09:54:00 PM (4 weeks ago)
Author:
peterwilsoncc
Message:

Login and Registration: Support /.well-known/change-password.

Introduce support for the ​Well-Known URL for Changing Passwords, a standardized URL for tools such as password managers to make change of password forms discoverable.

Per the specification this is only available to WordPress sites installed in the root directory of a domain. The URL example.com/.well-known/change-password will redirect a user to their profile page.

Introduces the filter wp_change_password_url to allow sites using a non-standard location for managing user passwords. If this is hosted on an another host, the host will need to be added to the allow list via the allowed_redirect_hosts filter in order to pass the wp_safe_redirect() validation process.

Developed in ​https://github.com/WordPress/wordpress-develop/pull/12621

Props audrasjb, ayeshrajans, hasnainashfaq, jns141191, johnbillion, masteradhoc, pfefferle, romainmrhenry, sajib1223, sergeybiryukov, swissspidy.
Fixes #51173.

Location:
trunk
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/canonical.php

    r64300 r64348  
    10791079                exit;
    10801080        }
     1081
     1082        /**
     1083         * Filters the well-known change password URL (/.well-known/change-password).
     1084         *
     1085         * By default visiting the well-known change password URL will redirect to
     1086         * the user's profile page when requested by a browser or password manager.
     1087         *
     1088         * Sites with a custom URL structure for modifying the passwords can modify
     1089         * the destination with this filter.
     1090         *
     1091         * The resulting URL is redirected using {@see wp_safe_redirect}, if the
     1092         * filtered URL is on an external host, that host will need to be included
     1093         * as an allowed host via the {@see 'allowed_redirect_hosts'} filter.
     1094         *
     1095         * @since 7.2.0
     1096         *
     1097         * @param string $change_password_url The URL to redirect to. Default is the user profile page.
     1098         */
     1099        $change_password_url = apply_filters( 'wp_change_password_url', admin_url( 'profile.php' ) );
     1100
     1101        /*
     1102         * The well-known change-password URL is always at the root of the origin
     1103         * per the spec (https://w3c.github.io/webappsec-change-password-url/), so
     1104         * only the root-relative path is matched here, regardless of whether
     1105         * WordPress is installed in a subdirectory.
     1106         */
     1107        if (
     1108                '/.well-known/change-password' === untrailingslashit( $_SERVER['REQUEST_URI'] )
     1109                && $change_password_url
     1110                && wp_safe_redirect( $change_password_url )
     1111        ) {
     1112                exit;
     1113        }
    10811114}
Note: See TracChangeset for help on using the changeset viewer.