I have a specific wordpress registration page where I have a new user complete their registration form. However, if someone clicks on the "forgot password" link in the login section of my site and then clicks on register, they'll be able to register for the site without going through the normal registation form. How can I redirect the wp-login.php?action=register page to sample.com/register ?

Thanks in advance!


Hook into login_form_register and throw people to your registration page with wp_redirect.

add_action( 'login_form_register', 'wpse45134_catch_register' );
 * Redirects visitors to `wp-login.php?action=register` to 
 * `site.com/register`
function wpse45134_catch_register()
    wp_redirect( home_url( '/register' ) );
    exit(); // always call `exit()` after `wp_redirect`

You can also hide the "register" link on that page by hijacking the user_can_register option on the login page. Hook into login_form_lostpassword and login_form_retrievepassword, from there add a filter to pre_option_users_can_register.

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 page.
function wpse45134_filter_option()
    // use __return_zero because pre_option_{$opt} checks
    // against `false`
    add_filter( 'pre_option_users_can_register', '__return_zero' );

As a plugin.

  • Thanks Christopher! Just one question, how do I implement this as a plugin? I've never created a wp plugin before but if you have a link for direction, etc. I'm comfortable with code and such – BentCircle Mar 10 '12 at 18:32
  • You would just copy and paste the code above into a single PHP file, put in the plugin header (codex.wordpress.org/Writing_a_Plugin#File_Headers), drop the PHP file into your wp-content/plugins directory. Here is the complete thing as a plugin gist.github.com/2012290 – chrisguitarguy Mar 10 '12 at 19:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.