Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to safely remove bp_adminbar_authors_menu using bp-custom?

  • @takuya

    Participant

    I want to remove bp_adminbar_authors_menu using bp-custom, not deleting whole function from bp-core files.

    I’ve copy and pasted full part of bp_adminbar_authors_menu to bp-custom as folllows.

    function bp_adminbar_authors_menu() {
    
    global $current_blog;
    
    if ( $current_blog->blog_id > 1 ) {
    
    $authors = get_users_of_blog();
    
    if ( is_array( $authors ) ) {
    
    /* This is a blog, render a menu with links to all authors */
    
    echo '<li id="bp-adminbar-authors-menu">';
    
    _e('Blog Authors', 'buddypress');
    
    echo '';
    
    echo '<ul class="author-list">';
    
    foreach( $authors as $author ) {
    
    $author = new BP_Core_User( $author->user_id );
    
    echo '
    
    ';
    
    echo 'user_url . '">';
    
    echo $author->avatar_mini;
    
    echo ' ' . $author->fullname;
    
    echo '<span class="activity">' . $author->last_active . '</span>';
    
    echo '';
    
    echo '<div class="admin-bar-clear"></div>';
    
    echo '
    
    ';
    
    }
    
    echo '';
    
    echo '';
    
    }
    
    }
    
    }

    And added

    remove_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu', 12 );

    But this caused wp-admin and wp-login not to load at all. Is deleting directly from bp-core files the only way?

Viewing 9 replies - 1 through 9 (of 9 total)
  • @djpaul

    Keymaster

    You can’t duplicate that function because PHP will complain about duplicate function names being declared (and whitescreen).

    You should be able to just put the remove_action line in, however priority may need to be 7. Have a play with a few values.

    @takuya

    Participant

    I just learned something new about PHP today, thanks.

    @takuya

    Participant

    7 doesn’t seem to work. Not even 1 or 5. Will have to play with more numbers…

    @djpaul

    Keymaster

    try something like

    function sp_test() {

    remove_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu' );

    }

    add_action( 'wp_footer', 'sp_test', 7 );

    @takeo

    Participant

    On a similar note… I wanted to remove one of the sidebars from the widget admin area since I won’t be using them all in my child template. I tried this but it did not work :( Spent a few hours researching and trying different things (including every possibly priority setting). No dice. I eventually gave up and hacked function file of the parent theme.

    function remove_sidebar() {
    unregister_sidebar('third-section');
    }
    add_action( 'admin_init', 'remove_sidebar');

    @takuya

    Participant

    DJPaul’s suggestion doesn’t still work. I’ll just delete from core. Thanks for everything!!

    @takeo

    Participant

    Interesting… neither of us are able to remove elements using a child custom.php file. The code in my example and your example could not be more simple. It should work. Weird.

    @takeo

    Participant

    Somewhat off-topic… but I solved my unregister_sidebars() problem if anyone is interested.

    https://buddypress.org/forums/topic/how-to-remove-a-sidebar

    @tedmann

    Participant

    For reasons I don’t completely understand, creating a bp-custom.php file with:

    remove_action('admin_footer', 'bp_adminbar_authors_menu' );

    works in the default BP site, but in the blog pages, the remove_action doesn’t appear to do anything. Could it be that the buddybar loads differently on individual blogs?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How to safely remove bp_adminbar_authors_menu using bp-custom?’ is closed to new replies.
Skip to toolbar