Skip to:
Content
Pages
Categories
Search
Top
Bottom

404 on Manage groups page

  • @danleachuk

    Participant

    I am attempting to hide the “Delete Group” sub nav item in Groups >> Manage, using the following code in bp-custom.php

    if(!current_user_can(‘administrator’)){
    bp_core_remove_subnav_item( bp_get_current_group_slug() . ‘_manage’, ‘delete-group’ );

    }}

    This does delete the item. However it has an unusual side-effect I don’t understand:

    groups/test/admin/ brings up a 404 error (without the code above, this brings up the Manage >> Details tab)
    groups/test/admin/edit-details still works after I type it in manually.

    How can I fix this?

    I have a fresh WP and BP install. Twenty-Sixteen theme.

Viewing 6 replies - 1 through 6 (of 6 total)
  • @henrywright

    Moderator

    Just a thought, have you considered a CSS solution?

    .tab {
        display: none;
    }

    @danleachuk

    Participant

    I did but I want to check for a specific user role beforehand.

    @henrywright

    Moderator

    In that case you could embed some CSS into the <head> section using the wp_head hook.

    Ref: https://codex.wordpress.org/Plugin_API/Action_Reference/wp_head

    @danleachuk

    Participant

    Would that work if I wanted to check the user was an editor and NOT an administrator?

    @danleachuk

    Participant

    Cracked it. Need to call bp_core_load_template after removing the navigation item.

    Final code:

    if(!current_user_can(‘administrator’)){
    bp_core_remove_subnav_item( bp_get_current_group_slug() . ‘_manage’, ‘delete-group’ );
    bp_core_load_template( ‘groups/single/settings/general’ );
    }
    }

    @henrywright

    Moderator

    display: none; wasn’t the best solution. Glad you found a better way 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar