Moving login form/logged in info to the admin bar
-
Hey everyone–
I’m trying to move the login form (if you’re logged out) or the avatar with username / logout link (if you’re logged in, from the search-login bar up to the admin bar. I’m trying to replace the logo in the admin bar because 1) I don’t really want it there and 2) I’m trying to de-clutter my header.
Moving the search box wasn’t tough since it’s staying in header.php, but moving the login code is a little tougher. It needs to be moved to bp-core-adminbar.php in the BuddyPress code, which is all straight PHP and not php within an HTML template. Converting the code has me somewhat confused, and I figure if anyone has 5 minutes worth of PHP training, this is a simple thing. That’s why I’m posting here — to see if anyone can help translate it.
The code in header.php that I need to move is…
<?php if ( !is_user_logged_in() ) : ?>
<form name=”login-form” id=”login-form” action=”<?php echo site_url( ‘wp-login.php’ ) ?>” method=”post”>
<input type=”text” name=”log” id=”user_login” value=”<?php _e( ‘Username’, ‘buddypress’ ) ?>” onfocus=”if (this.value == ‘<?php _e( ‘Username’, ‘buddypress’ ) ?>’) {this.value = ”;}” onblur=”if (this.value == ”) {this.value = ‘<?php _e( ‘Username’, ‘buddypress’ ) ?>’;}” />
<input type=”password” name=”pwd” id=”user_pass” class=”input” value=”” />
<input type=”checkbox” name=”rememberme” id=”rememberme” value=”forever” title=”<?php _e( ‘Remember Me’, ‘buddypress’ ) ?>” />
<input type=”submit” name=”wp-submit” id=”wp-submit” value=”<?php _e( ‘Log In’, ‘buddypress’ ) ?>”/>
<?php if ( ‘none’ != bp_get_signup_allowed() && ‘blog’ != bp_get_signup_allowed() ) : ?>
<input type=”button” name=”signup-submit” id=”signup-submit” value=”<?php _e( ‘Sign Up’, ‘buddypress’ ) ?>” onclick=”location.href='<?php echo bp_signup_page() ?>'” />
<?php endif; ?>
<input type=”hidden” name=”redirect_to” value=”<?php echo bp_root_domain() ?>” />
<input type=”hidden” name=”testcookie” value=”1″ />
<?php do_action( ‘bp_login_bar_logged_out’ ) ?>
</form>
<?php else : ?>
<div id=”logout-link”>
<?php bp_loggedin_user_avatar( ‘width=20&height=20’ ) ?> <?php bp_loggedinuser_link() ?> / <?php bp_log_out_link() ?>
<?php do_action( ‘bp_login_bar_logged_in’ ) ?>
</div>
<?php endif; ?>
I need to replace this within bp-core-adminbar.php…
// **** Default BuddyPress admin bar logo ********
function bp_adminbar_logo() {
global $bp;
echo ‘root_domain . ‘” id=”admin-bar-logo”>’ . get_blog_option( BP_ROOT_BLOG, ‘blogname’) . ”;
}
I just need help converting the if/else statements with the echos.
And, yes, I realize that this is mucking with things outside the template structure and will affect future upgrades.
- The topic ‘Moving login form/logged in info to the admin bar’ is closed to new replies.