Change Login & Register Links in Admin Bar
-
My theme has a built in lightbox for login and registration, but works only for it’s own login and and register links in the theme. I want the admin bar links for login and register to go to the light box login, so I needed to point the default admin bar login & register a tags to the lightboxes a tags.
For logged out users:
I want the Admin Bar Login link to point to:
<a data-reveal-id="tmpl_reg_login_container" href="javascript:void(0);" onclick="tmpl_login_frm();">Login</a>
I want the Admin Bar Register link to point to:
<a data-reveal-id="tmpl_reg_login_container" href="javascript:void(0);" onclick="tmpl_registretion_frm();">Register</a>
is there a functions snippet I can use to make this change?
-
I stumbled upon this post suggesting a snippet to put into bp-custom.php (a tweaks and snippets file for buddy press located in the plugins directory), but I can’t get it to work. I think there is an issue with my coding.
I am using BuddyPress 2.1.1
Here is my bp-custom.php file:
<?php // hacks and mods will go here //Change Admin Bar Login Links function custom_bp_adminbar_login_menu() { global $bp; global $wp; remove_action('bp_adminbar_menus', 'bp_adminbar_login_menu', 2); if (is_user_logged_in()) return false; echo '<li class="bp-login no-arrow"><a data-reveal-id="tmpl_reg_login_container" href="javascript:void(0);" onClick="tmpl_login_frm();">' . __('Log In', 'buddypress') . '</a></li>'; // Show "Sign Up" link if user registrations are allowed if (bp_get_signup_allowed()) { echo '<li class="bp-signup no-arrow"><a data-reveal-id="tmpl_reg_login_container" href="javascript:void(0);" onClick="tmpl_registretion_frm();">' . __('Sign Up', 'buddypress') . '</a></li>'; } } add_action('bp_adminbar_menus', 'custom_bp_adminbar_login_menu', 1); ?>
I am not a coder, but I’m looking for a snippet that can do this:
Add Function: Change Admin Bar Login and Register Links if user is logged out Remove WordPress/buddypress admin bar Login and Register links Add New Login and Register Links New Login Link: <a data-reveal-id="tmpl_reg_login_container" href="javascript:void(0);" onclick="tmpl_login_frm();">New Login Link</a> New Register Link: <a data-reveal-id="tmpl_reg_login_container" href="javascript:void(0);" onclick="tmpl_registretion_frm();">New Register Link</a> if user is logged in don't do any of the above (i.e.) show their buddypress username and hide register links, etc...
Does anyone know how to make this happen in code that I can drop into functions.php or bp-custom.php
I use the plugin “custom admin bar” to do this ( https://wordpress.org/plugins/custom-admin-bar/ ) (with a wp/bp site)
There are a ton of admin bar plugins in the wp plugin repo – certainly a few of them can handle this without getting into code?
- The topic ‘Change Login & Register Links in Admin Bar’ is closed to new replies.