How to Remove the Lost Password Link

To remove the Lost Password link from your WordPress login page, simply copy and paste the following code into your functions.php file. You can edit the functions.php file directly in the WordPress dashboard under Appearance > Theme Editor > Theme Functions or edit the file offline and upload using your favourite FTP program.

Følgende 3 koder er indsat nederst i functions.php der befinder sig i biblioteket

// Rettet af Hans Carl Oxenvad 20240316-1403
// Remove Lost Password Link
function vpsb_remove_lostpassword_text ( $text ) {
if ($text == ‘Lost your password?’){$text = ”;}
return $text;
}
add_filter( ‘gettext’, ‘vpsb_remove_lostpassword_text’ );

// Disable Password Reset URL & Redirect
function vpsb_disable_lost_password() {
if (isset( $_GET[‘action’] )){
if ( in_array( $_GET[‘action’], array(‘lostpassword’, ‘retrievepassword’) ) ) {
wp_redirect( wp_login_url(), 301 );
exit;
}
}
}
add_action( “login_init”, “vpsb_disable_lost_password” );

// Change WordPress Login Error Messages
add_filter(‘login_errors’,’login_error_message’);

function login_error_message($error){
//check if that’s the error you are looking for
$pos = strpos($error, ‘incorrect’);
if (is_int($pos)) {
//its the right error so you can overwrite it
$error = “Something went wrong! Please consult your system administrator”;
}
return $error;
}