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

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


Never mind. I was thinking too hard. This resolved it:

add_action( 'register' , 'register_replacement' );
function register_replacement( $link ){
	$link = str_replace('Site Admin' , 'Admin' , $link);
	return $link;
}

It was for WPMU.

On Wed, Aug 27, 2008 at 12:44 PM, Glenn Ansley <glenn at glennansley.com> wrote:
> Hi,
> 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;
>        else
>            $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?
>
> Thanks.
>


More information about the wp-hackers mailing list