The lost_password_html_link WordPress PHP Filter allows you to modify the link for users to reset their lost password.
Usage
add_filter('lost_password_html_link', 'your_custom_function', 10, 1); function your_custom_function($html_link) { // your custom code here return $html_link; }
Parameters
$html_link
(string): The HTML link to the lost password form.
More information
See WordPress Developer Resources: lost_password_html_link
Examples
Change the lost password link text
Customize the lost password link text.
add_filter('lost_password_html_link', 'change_lost_password_link_text', 10, 1); function change_lost_password_link_text($html_link) { return str_replace('Lost your password?', 'Forgot your password? Click here!', $html_link); }
Add a custom class to the lost password link
Add a custom CSS class to the lost password link.
add_filter('lost_password_html_link', 'add_custom_class_lost_password_link', 10, 1); function add_custom_class_lost_password_link($html_link) { return str_replace('<a', '<a class="custom-class"', $html_link); }
Change the lost password link URL
Change the URL for the lost password link to a custom URL.
add_filter('lost_password_html_link', 'change_lost_password_link_url', 10, 1); function change_lost_password_link_url($html_link) { return preg_replace('/href="([^"]+)"/', 'href="https://custom-url.com"', $html_link); }
Add an icon to the lost password link
Add a font-awesome icon to the lost password link.
add_filter('lost_password_html_link', 'add_icon_to_lost_password_link', 10, 1); function add_icon_to_lost_password_link($html_link) { return str_replace('Lost your password?', '<i class="fas fa-key"></i> Lost your password?', $html_link); }
Remove the lost password link
Completely remove the lost password link.
add_filter('lost_password_html_link', 'remove_lost_password_link', 10, 1); function remove_lost_password_link($html_link) { return ''; }