Disable user registration on WordPress

To disable user registration on a WordPress website, you can follow these steps:

Method 1: Using the WordPress admin dashboard

Log in to your WordPress admin dashboard.

Go to “Settings” and click on “General“.

Under the “Membership” section, you will find an option labeled “Anyone can register.” Make sure the checkbox next to it is unchecked.

Scroll down and click on the “Save Changes” button at the bottom to save your settings.

User registration will now be disabled on your WordPress website.

Disable user registration

 

Method 2: Adding functions code snippet on the site.

Yes, you can use a WordPress function or snippet to disable user registration. Here’s an example of a code snippet that you can add to your theme’s functions.php file or in a custom plugin:

[php]
// Disable user registration
function disable_user_registration() {
// Disable user registration by setting the ‘users_can_register’ option to false
update_option(‘users_can_register’, false);
}
add_action(‘init’, ‘disable_user_registration’);[/php]

By adding this code snippet, the user registration option will be disabled on your WordPress website. The update_option(‘users_can_register’, false) line sets the users_can_register option to false, preventing new users from registering.

Remember to save the changes to your theme’s functions.php file or activate the plugin containing this code for the changes to take effect.