This WordPress code completely disables user registration from the standard login page.
It performs several actions to secure and hide the registration option:
✅ Automatically redirects users to the homepage if they try to access the registration URL (wp-login.php?action=register).
✅ Removes the registration link from the admin bar.
✅ Disables the registration URL by returning an empty string.
✅ Cleans up registration-related messages on the login page.
📌 The goal is to prevent any manual user registrations through the standard WordPress interface, thereby strengthening the site’s security by strictly controlling account creation.
Paste the code into your child theme’s functions.php file.
// File : Disable user registration on WordPress login page.php
function disable_user_registration() {
if ($_SERVER['REQUEST_URI'] == '/wp-login.php?action=register') {
wp_redirect(home_url());
exit();
}
}
add_action('init', 'disable_user_registration');
function remove_register_link($wp_admin_bar) {
$wp_admin_bar->remove_node('register');
}
add_action('admin_bar_menu', 'remove_register_link', 999);
function remove_register_url($url) {
return '';
}
add_filter('register', 'remove_register_url');
function custom_login_message($message) {
if (strpos($message, 'register') !== false) {
$message = '';
}
return $message;
}
add_filter('login_message', 'custom_login_message');
No results available
Pour offrir une meilleure expérience, nous utilisons des cookies pour stocker et accéder aux informations des appareils. En consentant, nous pouvons traiter des données comme le comportement de navigation ou les ID uniques. Ne pas consentir peut affecter certaines fonctionnalités.