Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want a similar solution like this one for my login form on the backend of my WordPress installation: Forgot Password URL Filter

What I want to do instead of returning a custom forgot password url, I want to return a custom register link (all of this is on the login form at /wp-login.php). Basically I'm trying to white label WordPress completely, and I've got front end forms for creating and editing posts, registering, logging in, profile editing, and post management all in the front end. However, when someone attempts to login and that attempt is failed, they're redirected to /wp-login.php.

Ideally I could throw an error on my site and have it redirect to my front-end login page (is there a filter for that?), but worse case-scenario, I've rebranded my backend form so wordpress doesn't look like an issue (aside from the url being http://www.site.com/wp-login.php, but that's not a huge deal) What I want to know is if there's a filter so I can return a custom register link on the backend, and if possible even a custom login link back there too.

I've learned that there is a lostpassword_url filter, but as far as I know there isn't a register_url filter that I can use to change that.

Any help?

UPDATE

http://core.trac.wordpress.org/browser/tags/3.2.1/wp-login.php#L418

This is what I want to hook into with a filter to change.

share|improve this question

1 Answer 1

I'm not 100% sure, but it seems that the registration link is generated on general-template.php in wp-includes. Look at the function wp_register. Here you have a filter called register which you can use to filter the wp-login.php out.

/**
 * Display the Registration or Admin link.
 *
 * Display a link which allows the user to navigate to the registration page if
 * not logged in and registration is enabled or to the dashboard if logged in.
 *
 * @since 1.5.0
 * @uses apply_filters() Calls 'register' hook on register / admin link content.
 *
 * @param string $before Text to output before the link (defaults to <li>).
 * @param string $after Text to output after the link (defaults to </li>).
 * @param boolean $echo Default to echo and not return the link.
 */
function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {

    if ( ! is_user_logged_in() ) {
        if ( get_option('users_can_register') )
            $link = $before . '<a href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Register') . '</a>' . $after;
        else
            $link = '';
    } else {
        $link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
    }

    if ( $echo )
        echo apply_filters('register', $link);
    else
        return apply_filters('register', $link);
}

EDIT

add_filter('register', 'wpse28495_wpRegister');
function wpse28495_wpRegister($link) {
    if(!is_user_logged_in()) {
        $link = '<a href="' . site_url('my-login.php') . '">' . __('Register') . '</a>';
    }

    return $link;
}
share|improve this answer
    
I'm not entirely sure how add_filter() works. How would I apply this to change a link? Would I add an filter that calls a modified version of this function? –  Josh Allen Sep 14 '11 at 19:28
    
@Josh I've added a working example. The filter will change the default register URL from wp-login.php?action=register to my-login.php. –  rofflox Sep 14 '11 at 20:43
    
I've added this to my functions file, but it doesn't change the link at all. :/ –  Josh Allen Sep 14 '11 at 21:07
    
After looking at the backend more, it seems like this is the wrong function, like something that's added to the 'Meta' widget. In the backend, the HTML just involves a <p> and the registration link. Hmm. –  Josh Allen Sep 14 '11 at 21:11
    
The filter is for the function wp_register() which is used by WordPress in his widgets/themes. If you have another non-standard widget, you have to look at the sourcecode of these for a modification. –  rofflox Sep 14 '11 at 21:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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