The 'recovery_mode_begin_url' filter allows you to modify the URL that begins the recovery mode in WordPress.
This can be helpful if you need to customize the URL for a specific purpose or enhance security.
Usage
To use this filter, create a function and hook it to 'recovery_mode_begin_url'. Then, return the modified URL.
function modify_recovery_url( $url, $token, $key ) {
// Modify the $url as needed
return $url;
}
add_filter( 'recovery_mode_begin_url', 'modify_recovery_url', 10, 3 );
Parameters
- $url (string) – The generated recovery mode begin URL.
- $token (string) – The token used to identify the key.
- $key (string) – The recovery mode key.
Examples
Add a custom prefix to the recovery URL
Function: add_custom_prefix_to_recovery_url
function add_custom_prefix_to_recovery_url( $url, $token, $key ) {
return 'custom-prefix-' . $url;
}
add_filter( 'recovery_mode_begin_url', 'add_custom_prefix_to_recovery_url', 10, 3 );
This function adds a custom prefix to the recovery mode URL, making it more unique.
Change the recovery URL domain
Function: change_recovery_url_domain
function change_recovery_url_domain( $url, $token, $key ) {
$new_domain = 'https://custom-domain.com';
return str_replace( home_url(), $new_domain, $url );
}
add_filter( 'recovery_mode_begin_url', 'change_recovery_url_domain', 10, 3 );
This function replaces the original domain in the recovery URL with a custom domain.
Add a timestamp to the recovery URL
Function: add_timestamp_to_recovery_url
function add_timestamp_to_recovery_url( $url, $token, $key ) {
$timestamp = time();
return $url . '×tamp=' . $timestamp;
}
add_filter( 'recovery_mode_begin_url', 'add_timestamp_to_recovery_url', 10, 3 );
This function appends the current timestamp to the recovery URL to make it time-sensitive.
Add a custom parameter to the recovery URL
Function: add_custom_parameter_to_recovery_url
function add_custom_parameter_to_recovery_url( $url, $token, $key ) {
return $url . '&custom_parameter=value';
}
add_filter( 'recovery_mode_begin_url', 'add_custom_parameter_to_recovery_url', 10, 3 );
This function adds a custom parameter and value to the recovery mode URL.
Encode the recovery URL
Function: encode_recovery_url
function encode_recovery_url( $url, $token, $key ) {
return urlencode( $url );
}
add_filter( 'recovery_mode_begin_url', 'encode_recovery_url', 10, 3 );
This function encodes the recovery URL, making it less readable and harder to modify by unauthorized users.