[wp-hackers] $before and $after variables when filtering wp_register()

Glenn Ansley glenn at glennansley.com
Wed Aug 27 16:44:12 GMT 2008

I was trying to apply the filter for wp_register() found online 44 of
wp-includes/general-template.php and defined below:

function wp_register( $before = '<li>', $after = '</li>' ) {

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

    echo apply_filters('register', $link);

It's easy enough to add a filter to my plugin and replace the link
text but I found that the $before and $after variables aren't passed
to the filter. It gets the link variable with $before and $after
already attached. If I wanted to take into consideration the chance
that someone has defined their own before and after other than line
items, would I have to do a substr() call or has WP provided another
option that I am missing?


More information about the wp-hackers mailing list