Hide Links on the Login Page
Removes the "Go to site", "Lost your password?" and privacy policy links from the login screen, each one switchable on its own.
Opens WPIDE on
Code
// Choose which links to hide.
$wpide_hide_login_links = array(
'back_to_site' => true, // "← Go to Site Name"
'lost_password' => false, // "Lost your password?"
'privacy' => true, // Privacy policy link
);
add_action( 'login_enqueue_scripts', function () use ( $wpide_hide_login_links ) {
$selectors = array();
if ( ! empty( $wpide_hide_login_links['back_to_site'] ) ) {
$selectors[] = '#backtoblog';
}
if ( ! empty( $wpide_hide_login_links['privacy'] ) ) {
$selectors[] = '.login .privacy-policy-page-link';
}
if ( $selectors ) {
wp_add_inline_style( 'login', implode( ',', $selectors ) . '{display:none !important;}' );
}
} );
add_filter( 'lost_password_html_link', function ( $html ) use ( $wpide_hide_login_links ) {
return empty( $wpide_hide_login_links['lost_password'] ) ? $html : '';
} );
Notes
Hiding the lost password link does not disable password resets.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.