Saunt Valerian
Expert
Member of the Month
Member Likes (0)
Trying to create a function that will parse the Register link in the admin bar to change the text. I've got it deployed on multisite and I want to clarify how it reads.
I want it to say something like "Register a new [insert network name] account"
This is what I have so far but it isn't working (there is probably something more complex needed), cqn anyone help me tune this up?
// Change the default register link to something branded
function branded_register_link() {
echo '<a href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Register a new network account') . '</a>';
}
add_action( 'wp_register', 'branded_register_link',);
The original code snippet (as far as I can tell) comes from wp-includes/general-template.php and it is this:
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);
}

Responses (12)
Support Zombie (joined January 2012) Likes (0)
hey @Saunt Valerian that works fine untill you are on your network or primary domain dashboard then it puts a call into plugins.php and throws a php error. The only other issue is that the function will have to be added to each themes functions.php file and could be over written if not using a child theme.
Member (joined February 2011) Likes (0)
I've got it deployed in a mu-plugin as part of my admin bar mods. I'm not getting an error with it that way, I'm just not getting anything.
Member (joined February 2011) Likes (0)
Arrghh. I'm on the wrong path!
The function from wp-includes/general-template.php is not what I need to be modifying. Just as a test I changed the text in the original function in the core file and it had no impact on the wpadminbar link. I find out where the admin bar link is created and modify that function. That's why I wasn't getting anything response from my code.
Support Zombie (joined January 2012) Likes (0)
try this
function wp_admin_bar_edit_menu
Support Zombie (joined January 2012) Likes (0)
this is quite a cool article i read a while back, it completely replaces the the default tool bar before it renders
http://wp.smashingmagazine.com/2012/03/01/inside-the-wordpress-toolbar/
Member (joined February 2011) Likes (0)
I'm taking a look at that, in the meantime, it is probably worthwhile to mention that this is also on buddypress. I forgot that buddypress integrates a lot of stuff in the admin bar now, I probably need to be looking in the BP plugin folder.
Member (joined February 2011) Likes (0)
Okay @tom.eagles using the information you provided me above, I went a different direction with it and simply added a new menu item to the bar and used css to hide the built in one. I know its not elegant, but I'm getting the functionality that I need.
Now I need to figure out how to add a CSS class to the array so that I can trigger my ajax registration form on the subsites (I don't want folks navigating away from the subsites, I want them to register right there). I just don't understand the syntax, or if WP even supports adding a CSS class to a adminbar menu item. Do you, or does anybody else know how to do this?
This is what I have:
I've got it deployed in a mu-plugin, but it would work just as well as its own plugin in single site, or in a theme's functions.php.
Support Zombie (joined January 2012) Likes (0)
you could try this
just checked in chrome using view element and the whole admin bar can be controlled in my themes case it was in the skins styling. so if you ca add it to the array just tag them.
unless i am misreading what you meant
Member (joined February 2011) Likes (0)
Well, I've got css class added, and it is showing up in view element, but it isn't being applied because it the class ab-item is overriding it.
I figured out the syntax to add the css class to the meta array this way:
I'm getting the basic functionality, but I'm not getting the ajax behavior that I'm supporting on my network. I think what I have is a good stopgap measure, but I think I'm going to continue to look for help on a getting a simple function to change the word "Register" - using the original link will allow me to make use of BuddyDev's Ajax registration plugin because that already works with the default link.
Member (joined April 2009) Likes (0)
Neat stuff! Just chiming in to subscribe myself to this feed and see whatelse you guys come up with.
sub-site user registration is a sore point at the moment for WordPress.
Member (joined February 2011) Likes (0)
Subsite registration on a buddypress network is actually very nicely handled by BuddyDev's BP Ajax Registration. http://buddydev.com/plugins/bp-ajax-registration/
It uses javascript to hook into the Register and Sign-up links in the Buddybar and WP admin bar. It can also be added to any register link by adding a css class. It is the reason for this thread. Clicking the default links brings up a nice modal overlay of the BP registration screen. I really can't imagine a BP/multisite network without it. Its the reason I'm looking to modify the existing BP Register link instead of replace as I've done so far. I want new members to sign up easily for my network on the subsites.
Even though it isn't working in my admin bar at the moment, you can see it in action at http://hitchhikersguide.teatra.de/help-wanted/ just click the new account link on that page and you'll be presented with the modal.
Member (joined February 2011) Likes (1)Liked by: 
Solved! Brajesh at BuddyDev gave me the correct CSS class to use to trigger the modal for his BuddyPress Ajax Registration.
The following code properly hides and replaces the default BP registration link and adds the correct class to work with the ajax plugin. I find it works perfectly. I've deployed in a mu-plugin, but it will also work as a standalone plugin network-activated or as a snippet in bp-custom.php
You can see this setup in action anywhere on the network here: http://teatra.de
If you aren't running the ajax reg. plugin, but just want to replace the text of the link, you could still use this, just delete the meta array in lines 21-23 below. To use it for your purposes, edit the title and href as needed for your network.
Become a member