Build noteOct 11, 2024
Disable WordPress Registration – Here's How!
To disable the default registration page of WordPress (/wp-login.php?action=register) while still allowing registration through WooCommerce, you can do the following:
Add the following code to your theme's functions.php file or use a plugin for custom code snippets to avoid making 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 homepage (or another page of your choice).