Skip to:
Content
Pages
Categories
Search
Top
Bottom

Deleting Admin Sub-menu items

  • Avatar of adenicol
    adenicol
    Participant

    @adenicol

    I am creating administrators for each of my group on my website. The groups are pre-created and I want to limit what the administrators can do. There are only two things I am still struggling with…

    When an administrator goes to their club they have the admin menu (Home, Members, Invite, Admin, etc…). When they click on Admin they have a sub menu which has Details, Settings, Avatar, Members, Requests, Extras, and Delete. I want to remove the Extras and Delete options from that menu.

    I was able to find instructions on how to delete the items from the first menu (like Invite, Admin) but I need the admin to stay but not have all it’s options.

    Does anyone know what code I would have to place in my functions/BP Options file to get the Extras and Delete options to not display?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Avatar of danbpfr
    danbpfr
    Participant

    @chouf1

    hi @adenicol,

    you’re using the old buddybar or an old BP version, right ? Here is a solution to remove items in BP 1.5 > 1.6.x with buddybar activated, but be aware that some menus changed place in the upcoming BP 1.7

    So if you mean the WP Toolbar (like here the black one on top) witch holds the group admin options, the code sit in bp-groups/bp-groups-buddybar.php

    This contains only one function. Simply copy it to your (preferably child) theme functions.php, rename it, do your changes (html remove, ad/remove conditinals),  deactivate the original filter and register.

    original function is bp_groups_adminbar_admin_menu()

    rename it to my_bp_groups_adminbar_admin_menu() (or what you want)

    and do the same in the action filter.

    original: add_action( ‘bp_adminbar_menus’, ‘bp_groups_adminbar_admin_menu’, 20 );

    modified: add_action( ‘bp_adminbar_menus’, ‘my_bp_groups_adminbar_admin_menu’, 20 );

    Resume

    remove_action( ‘bp_adminbar_menus’, ‘bp_groups_adminbar_admin_menu’, 20 );
    function my_bp_groups_adminbar_admin_menu() {

    bla bla

    }

    add_action( ‘bp_adminbar_menus’, ‘my_bp_groups_adminbar_admin_menu’, 20 );

    Avatar of adenicol
    adenicol
    Participant

    @adenicol

    Thanks for the reply. I’m using 1.6 but that isn’t the menu I wanted to edit. When I click on a club it takes me to that club page, this is what I wanted to edit.

    Screen Shot of menu I want to edit

    Avatar of danbpfr
    danbpfr
    Participant

    @chouf1

    ok, go to bp-members/bp-members-buddybar.php:108 (bp 1.6)

    function bp_members_adminbar_admin_menu()

    same routine as on previous answer

    Avatar of adenicol
    adenicol
    Participant

    @adenicol

    Is there a way to do that without changing the core file? If I have to update later I would prefer not to have the items start showing again and me have to go and modify the file again.

    Avatar of adenicol
    adenicol
    Participant

    @adenicol

    I found a workaround for this…I dropped the page content in to a buffer and then just modified that with PHP. Now if I upgrade the script should still strip out the links.

    Avatar of danbpfr
    danbpfr
    Participant

    @chouf1

    @adenicol,

    why did you asked in your first post what to put into your themes functions.php ? Thought his was the right place to put the changed function. The only thing you have to do is to create a child theme so you will never loose the change you did after an upgrade.

    That’s why child theme is for !

    Don’t make over complicated things. I never tell you to hack the core file.

    Avatar of adenicol
    adenicol
    Participant

    @adenicol

    I’m sorry, I thought when you said to rename the function you meant to rename the original function in the core files and leave the other function with the original name. I’ll try it the other way around. I’d rather this worked than doing the other workaround I did.

    Avatar of danbpfr
    danbpfr
    Participant

    @chouf1

    the thing to understand with PHP is to never use a function name twice on a same action. A function name is and must be unique.

    In the WP ecosystem, you can act on templates throught the child theme. Generally you only change HTML and CSS and use the existing php filters from the original template.

    If you need to modify an existing function, you copy the original to the child theme functions.php file and do your changes on this copy. Once done, you change the name of the function and the new hook name

    unhook first  the action or the filter
    remove_action or remove_filter, than the new function
    function my name
    add_action or add_filter (‘the_action_to_hook’, ‘my_name’)

    Because this is registered in the theme functions file, and because WP is calling a evantually exiting child theme first when he loads, the child becames priority of any other existing theme. And that’s why it works !

    Don’t be affraid, the only one who can broke things in a child theme is you, never an update.

    The only limit is when you use a so called buddypress ready theme, in fact a third party theme. This works generally¬† out of the box, but if you want to change something in such a theme, you must first create a child for it. Simply because that original “child” is updatetable. And the whole world knows that you want’t loose your changes.

    That said it’s not forbidden to work on a local copy, and to save systematically any file you modify on the prod site.
    Reading the Codex on rainy days is also a good thing you can do. :-)

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

You must be logged in to reply to this topic.