Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] how hide tab only for user? not remove/disable

  • @masoud1111

    Participant

    hi.
    i want to hide some tabs only for non-admins.
    for example “Compose
    underMessage > Compose.
    in bp-messages/classes/class-bp-component.php lines:199 & 287.
    it’s possible to add a conditional if().

    <strong>if(current_user_can(administrator))</strong>
    {
    $sub_nav[] = array(
    'name'=> __( 'Compose', 'buddypress' ),
    'slug'=> 'compose',
    'parent_url'=> $messages_link,
    'parent_slug'=> $slug,
    'screen_function'=> 'messages_screen_compose',
    'position'=> 30,
    'user_has_access'=> $access
    }

    and do this for line 287.
    so, both the Compose tab and the ability to composing a msg will be in admin hands.
    BUT it’s not a good way to hack core codes!
    so how can i do this?

    the things i want to hide from non-admins:
    1) Notification tab
    2) Compose (sub-nav)
    3) hide the panel and restrict the access to change Account email (from Setting > General)

    thanks in advance.

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

    Participant

    Give this a try: (add to bp-custom.php) 1) & 2):

    function bpfr_hide_tabs() {
    global $bp;
    
    	if ( bp_is_user() && !is_super_admin() ) {
    		bp_core_remove_nav_item( 'notifications' );
    		bp_core_remove_subnav_item( 'messages', 'compose' );
    	}
    	
    }
    add_action( 'bp_setup_nav', 'bpfr_hide_tabs', 15 );

    3) With BP and xprofile component activated, a user doesn’t need access to WP dashboard. He can change his profile credentials from front-end.
    Easiest way would be to use this plugin.

    Retrieving them the possibility to change their email is anyway not a good idea. What happen when a user changed from yahoo to gmail, but can’t login because he lost his password ? Where will the new pwd be sent ?

    Perhaps you have also to remove this from the BP usermenu on toolbar ?
    Here’s how you can do it:

    function admin_bar_remove_this(){
    global $wp_admin_bar;
    	$wp_admin_bar->remove_node('my-account-messages-compose');
    }
    add_action('wp_before_admin_bar_render','admin_bar_remove_this');

    @masoud1111

    Participant

    @danbp
    first of all i have to thank you for your quick answer and great support.
    i am very satisfied with the support of this plugin. you guys are great.
    thank you very much.
    —-
    1 & 2 ) the function worked great, but the “private message” button in profile still remains!
    i mean if a user can not send message so there is no need to show them that button.
    is it possible to show that button only to admins too?

    3)
    oh no no. i didnt mean WP DASHBOARD.
    i dont want users to be able to change their email account on their own, after sign-up(bp sing up form), unless they contact admin of site, and request the change of email.
    the option of changing email account is in
    Setting Tab > General Tab
    there is a place for them to write their new email and …
    i want to hide and disable it for normal users and available only for admin.
    look at this picture please.
    the red area.

    @danbp

    Participant

    @masoud1111,

    thank you for your appreciation. And sorry for my confusion about setting > general. That’s traditionnally the path used on admin dashboard. In regard of the picture, it’s the mandatory wp registration email field. This part is on your-site/members/USERNAME/settings.

    The template file you can modify is members/single/settings/general.php
    In that file is a form who contains a label and a input type for “email”. To hide, you could add a conditionnal for admin’s only.

    For example, before both label and input lines, add

    <?php if(is_super_admin() ): ?>
       <label>bla
       <input>bla
    <?php endif; ?>

    To be complete, you may want to show message to explain about the email field. In that case, add something like following above:

    
    <?php if ( !is_super_admin() ) : ?>
    <p>Ask site admin if you want to change your email address.</p>
    <?php endif; ?>

    @shanebp

    Moderator

    Re private message button, try:

    function masoud_remove_private_message_button( $button ) {
    
         if ( ! is_super_admin() )
    	$button = '';
    
         return $button;
    }
    add_filter( 'bp_get_send_message_button', 'masoud_remove_private_message_button', 1 , 1 );

    @masoud1111

    Participant

    @danbp
    thanks for your complete explanation. but there is not such a file members/single/settings/general.php in my socialchef theme.
    and yes, i do have a buddypress folder in my socialchef theme.
    so i created the path. and copied the general.php from buddypress plugin files to the destination folder.
    and did the changes as i want.
    thanks a lot.

    @masoud1111

    Participant

    @shanebp
    hi, the function worked very well.
    and thanks for your help.

    @masoud1111

    Participant

    @danbp
    do i need to update the codes in my theme manually, everytime you roll an update for the plugin?
    because as it’s said in many places, when i create a folder named “Buddypress”
    in my theme, it will override the original. correct?

    for example. now it’s version 2.5.3 and i copied the general.php from plugin in my theme’s buddypress folder.
    so when the version 2.6.0 is out, do i need to copy and replace general.php from plugin to theme again?(as to use the most recent codes)?

    so do i need to? or not?

    sorry for my question, if it sounds stupid.

    @sharmavishal

    Participant

    do i need to update the codes in my theme manually, everytime you roll an update for the plugin?

    that depends if its a major update which affects the page you modified.

    when i create a folder named “Buddypress” in my theme, it will override the original. correct?

    correct

    @masoud1111

    Participant

    @sharmavishal
    hi. thanks for the answer, i got it.

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