Many WordPress sites don’t need to offer the option for users to register and often find spam users created which clog up your database and can cause problems down the line. Most spam users will register on your WordPress website by using the default register link found on the login screen, this can easily be removed which will reduce the number of spam user registrations on your website.
To remove the register link from the WordPress login.php screen you will need to add a small function to your theme functions.php file or create a WordPress MU plugin. We recommend using an MU plugin as this will be used no matter what theme you use and can’t be deactivated by accident by other site administrators.
Function to remove the register link from WordPress login.php
/** * Remove the register link from the wp-login.php script * https://wphelper.site/remove-register-link-wordpress-login/ */ add_filter('option_users_can_register', function($value) { $script = basename(parse_url($_SERVER['SCRIPT_NAME'], PHP_URL_PATH)); if ($script == 'wp-login.php') { $value = false; } return $value; });
This function will remove the register link completely which is a better method than removing the link with CSS. If you remove the link using CSS most bots will still find it as they will crawl the page HTML ignoring the CSS.
If you get stuck with adding this function to your site please leave a comment below or contact us.
Kudos to you! It works like a charm.
Thank you for this, works…!
Works great thanks !!!
Does this method only remove the “Register” link on the login page, but still allows people to register by another method? My users register by purchasing and enrolling in online courses using LearnDash LMS and WooCommerce. New user creation is handled by the plugins. I have a custom login plugin that has a setting for “Remove “Register | Lost your password?” link”. In other words, either both links show, or none. I need to keep the lost password feature, but since I use a different registration process, the standard WP register link is invalid. I just want to remove that Register link, but in the WP settings, keep “Anyone can register” checked. Thanks.