Leave a Reply

1 comment

  1. Let’s follow the white rabbit.

    http://core.trac.wordpress.org/browser/tags/3.3.1/wp-login.php#L414

    …can’t be changed, it’s hardcoded. However it leads to here when clicked:

    http://core.trac.wordpress.org/browser/tags/3.3.1/wp-login.php#L481

    …which has a wp_signup_location filter for multisite, which in case your site !is_multisite() will never fire off. If you’re multisite – stop here.

    add_filter( 'wp_signup_location', 'wpse_46848_hijack_the_back' );
    function wpse_46848_hijack_the_back( $location ) {
        return 'my-registration-page-is-better.php';
    }
    

    Not multisite, eh?

    registration_redirect is what happens AFTER registration, yet it’s called before displaying the registration page. We can play dirty and hook into it and diverge into a wp_redirect with an exit() before displaying anything from the original page.

    add_action( 'registration_redirect', 'wpse_46848_hijack_the_back' );
    function wpse_46848_hijack_the_back( $redirect_to ) {
        wp_redirect( 'my-registration-page-is-better.php' );
        exit();
    }
    

    Note, that both add_action and add_filter work in the same way (add_action calls add_filter), and although it’s generally not advisable to mix them as things will get confusing, semantically you’re hijacking with the filter with an action, not a filter (since you’re not returning anything). If you prefer to stick to strict “a filter is a filter, an action is an action” rules do this:

    add_filter( 'registration_redirect', 'wpse_46848_hijack_the_back' );
    function wpse_46848_hijack_the_back( $redirect_to ) {
        wp_redirect( 'my-registration-page-is-better.php' );
        return exit();
    }