Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Don't allow people to view the default WordPress registration page
Plugin Name: Registration Redirect
Description: Don't allow people to view the default registration page
Author: Christopher Davis
Author URI:
License: GPL2
add_action( 'login_form_register', 'wpse45134_catch_register' );
* Redirects visitors to `wp-login.php?action=register` to
* ``
function wpse45134_catch_register()
wp_redirect( home_url( '/register' ) );
exit(); // always call `exit()` after `wp_redirect`
add_action( 'login_form_lostpassword', 'wpse45134_filter_option' );
add_action( 'login_form_retrievepassword', 'wpse45134_filter_option' );
* Simple wrapper around a call to add_filter to make sure we only
* filter an option on the login reset password page.
function wpse45134_filter_option()
// use __return_zero because pre_option_{$opt} checks
// against `false`
add_filter( 'pre_option_users_can_register', '__return_zero' );

You could also use the login_redirect filter.


chrisguitarguy commented Mar 11, 2012

I don't think that applicable for this use case. They just wanted to stop people from viewing the default registration form.

Ah, ok. I thought this was a more general version as a plugin.


chrisguitarguy commented Mar 11, 2012

Nah, good idea for a plugin, though!

login_form_{$action} fires right after login_init, so it's a bit different than login_redirect.

This plugin is currently not letting me goto /wp-admin once logged in as an admin. Any suggestions on how I could edit the plugin to allow access to wp-admin?

madivad commented Sep 12, 2017

Chris, awesome piece of work here. I originally tried a filter on [register_url](, for whatever reason, it didn't work. Not sure what I did wrong there, but this code worked perfectly. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment