Skip to:
Content
Pages
Categories
Search
Top
Bottom

Remove “Blog Owners” From Admin Bar for ONE Blog Only?

  • I have a sitewide tag search blog up using the Sitewide tags plugin for WPMU. I have a special BP child theme that I’m using to integrate it inot the main site. My question is how could I hide the “Blog Owners” menu item from the admin bar for ONLY this child site (so that it looks exacly like my main site’s bar)?

    I tried doing display:none; on #bp-adminbar-authors-menu in the CSS, but that didn’t do anything. I know it’s way wrong (because it didn’t do squat when I tried it), but I also tried adding this to my child theme’s functions.php

    function bp_adminbar_authors_menu() {
    global $bp, $current_blog, $wpdb;

    if ( $current_blog->blog_id == 12 || !function_exists( ‘bp_blogs_install’ ) )
    return false;

    Anyone know how I’d do this?

Viewing 12 replies - 1 through 12 (of 12 total)

  • Brajesh Singh
    Participant

    @sbrajesh

    Put this code in your bp-custom.php or child theme’s functions.php


    add_action("init","bpdev_remove_author_link");
    function bpdev_remove_author_link(){
    global $current_blog;
    if($current_blog->blog_id==12)
    remove_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu', 12 );
    }

    I hope that should do it.
    You can change that 12 to any blog id in the line if($current_blog->blog_id==12)

    @sbrajesh, thanks so much for the reply! Unfortunately, that didn’t work in either file :(


    Brajesh Singh
    Participant

    @sbrajesh

    Are you sure you made the appropriate change and put the correct blog id in the conditional. I just tested it on my second blog with id 2 and the code in bp-custom.php, It worked. Please make sure to put correct blog id in the “if…” condition.
    And do not change the priority of remove_action, leave it as it is.

    @sbrajesh: Wait!You’re correct! It DOES seem to have removed the stuff that drops down from the “Blog Owners” menu (the name and avatar of the owner of blog 12), but I need the actual “Blog Owners” text removed from the admin bar completely.


    Brajesh Singh
    Participant

    @sbrajesh

    @justinbishop
    I guess I am mistaken somewhere, do you mean the blog authors menu, if yes, then It will remove that “blog author” and the drop down completely. If you meant something else, then I may be mistaken.

    @sbrajesh: On the following site, I want to get rid of the text “Shop Owners” (and the downward arrow, of course) in the BP admin bar so that it looks exactly like my main site’s bar

    http://www.clothunderground.com/search/

    As you can see, using the code you posted did cause the “Shop Owners” menu to not drop down and show the name/avatar of the site owner of this particular blog, but it didn’t get rid of the “Shop Owners” text in the admin bar itself.


    Brajesh Singh
    Participant

    @sbrajesh

    Thanks for pointing to the site. It seems by checking the code, that link is not added by the buddypress but is added by some other plugin. Can you name that plugin, since we need to get rid of an action hook associated with that plugin.

    @sbrajesh: Eeek! I have no idea what plugin would do that! I certainly don’t remember installing one with that as my goal!

    I did edit the .po file to change all instances of “blog” to “shop”, so all but the display terminology should be the same as the “blog owners” link that is in the default Buddypress install :/

    OK, I found this in bp-core-adminbar.php. Say I wanted to get rid of the text “Blog Authors”, but only for blog ID# 12:

    // **** “Blog Authors” Menu (visible when not logged in) ********
    function bp_adminbar_authors_menu() {
    global $bp, $current_blog, $wpdb;

    if ( $current_blog->blog_id == BP_ROOT_BLOG || !function_exists( ‘bp_blogs_install’ ) )
    return false;

    $blog_prefix = $wpdb->get_blog_prefix( $current_blog->id );
    $authors = $wpdb->get_results( “SELECT user_id, user_login, user_nicename, display_name, user_email, meta_value as caps FROM $wpdb->users u, $wpdb->usermeta um WHERE u.ID = um.user_id AND meta_key = ‘{$blog_prefix}capabilities’ ORDER BY um.user_id” );

    if ( !empty( $authors ) ) {
    /* This is a blog, render a menu with links to all authors */
    echo ‘

  • ‘;
    _e(‘Blog Authors’, ‘buddypress’);
    echo ‘
    ‘;

    echo ‘

    ‘;
    echo ‘

  • ‘;
    }
    }

Also, I tried to do display:none; for #bp-adminbar-authors-menu in the CSS file of my child theme, but that didn’t seem to do anything. I would like to just do away with that entire “li” for blog ID# 12, though.

(it’s actually 14, I was mistaken when I started this thread, but I’m still calling it #12 for continuity’s sake)


Brajesh Singh
Participant

@sbrajesh

Ok, here is a css solution.

#wp-admin-bar ul li#bp-adminbar-authors-menu{display:none;}

It will remove that for 100% sure if you put it at the bottom of the child theme css.

but I still believe that drop down has something to do with some other plugin, as your bp-core-adminbar.php says it as “Blog Author” while the list says “Shop Owners”

Thanks! I’ll try that ;)

And no, not a plugin, I just edited the Buddypress .po file to change the wording.

ETA: GAHH!! That worked! Thank you so much! Figures it would be a simple CSS thing. I just hadn’t been able to get the syntax quite right :P

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Remove “Blog Owners” From Admin Bar for ONE Blog Only?’ is closed to new replies.
Skip to toolbar