Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to hide tabs on the Sitewide Activity page


  • HDcms
    Participant

    @hdcms

    Hello,

    There are many examples to hide the navigation on a profile bp_core_remove_nav_item(‘friends’ );.
    How to hide tabs on the Sitewide Activity page ?

    Regards

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

  • Boone Gorges
    Keymaster

    @boonebgorges

    These tabs are hardcoded into the theme template. So you have two options:

    1. Override the theme template in your own theme (copy /wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/activity/index.php to /wp-content/themes/[your-theme]/buddypress/activity/index.php, open the copied template, and remove the tabs you don’t want.

    2. Hide with CSS. Eg

    
    body.activity.directory #activity-friends {
        display: none;
    }
    

    HDcms
    Participant

    @hdcms

    Hello Gorges
    And thank you 🙂

    In fact, I want to hide these tabs to everyone except for a wordpress role and the super admin
    It works (a priori) but do not hesitate to suggest an improvement.
    I am not sure of my code!

    Regards

    add_action('wp_head', 'HD_maj_activite');
    function HD_maj_activite() {
    	$bp_loggedin_user_id = bp_loggedin_user_id();
    	$user_info = get_userdata($bp_loggedin_user_id);
    	$user_roles = $user_info->roles;
    	if (is_super_admin() || in_array('membre2', $user_roles)) 
     	return ;
    	$output .= '<style type="text/css">body.activity.directory #activity-friends {display: none;}</style>';
    	$output .= '<style type="text/css">body.activity.directory #activity-groups {display: none;}</style>';
       echo $output; // 
    }

    HDcms
    Participant

    @hdcms

    Hello,

    Ah, I have error messages. but I do not see how to correct!

    04-Dec-2017 09:42:49 UTC] PHP Notice:  Trying to get property of non-object in /home/../wp-content/themes/woffice-am/bp-am/bp-membres.php on line 7 
    => $user_roles = $user_info->roles;
    [04-Dec-2017 09:42:49 UTC] PHP Warning:  in_array() expects parameter 2 to be array, null given in /../wp-content/themes/woffice-am/bp-am/bp-membres.php on line 8 
    => if (is_super_admin() || in_array('membre2', $user_roles))
    [04-Dec-2017 09:42:49 UTC] PHP Notice:  Undefined variable: output in /home/../wp-content/themes/woffice-am/bp-am/bp-membres.php on line 10 
    => $output .= '<style type="text/css">body.activity.directory #activity-friends {display: none;}</style>';

    HDcms
    Participant

    @hdcms

    Hello,
    Still unresolved.
    If anyone can help me solve it
    Have a good day

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