Deactivate WordPress registration – here’s how!

Marc Wagner, October 11, 2024

To deactivate the default registration page of WordPress (/wp-login.php?action=register) and at the same time enable registration via WooCommerce, you can do the following:

Add the following code to the functions.php file of your theme or use a plugin for custom code snippets to avoid direct changes to the theme files:

function disable_wp_registration() {
    if (isset($_GET['action']) && $_GET['action'] == 'register' && !is_admin()) {
        wp_redirect(home_url());
        exit;
    }
}
add_action('login_init', 'disable_wp_registration');

This code checks if someone is trying to access the WordPress registration page and then redirects them to the home page (or any other page you prefer).

Avatar of Marc Wagner
Marc Wagner

Hi Marc here. I'm the founder of Forge12 Interactive and have been passionate about building websites, online stores, applications and SaaS solutions for businesses for over 20 years. Before founding the company, I already worked in publicly listed companies and acquired all kinds of knowledge. Now I want to pass this knowledge on to my customers.

Similar Topics

Comments

Leave A Comment