1

This is probably very simple, but I would like to add a hook to my theme's functions.php file in order to change the Register link on the login page (wp-login.php).

How would I do that?

4

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();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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