Skip to:
Content
Pages
Categories
Search
Top
Bottom

Buddypress Activity Control


  • cl0ne
    Participant

    @cl0ne

    Hello all!

    I’ve come across the subject a bunch of time but the solution I’m looking for hasn’t presented itself. Basically, I’m trying to prevent members/users from having any kind of access to the Activity component. The purpose of the website I’m designing is to establish private connection between other members. There’s no need for a wall, mentions, favorites, etc. The whole activity component can be hidden from regular members/users. However! I need it to function the way it is. Meaning, I need it hidden but not disabled. The admin should have access to it and should be able to view all pertinent activity such as newly registered members, new friendships, etc, in the back-end.

    How can this be accomplished?

    Thanks so much!

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

  • shanebp
    Moderator

    @shanebp

    I think you want to disable the Activity component for everyone except site admins.

    If so, the solution is in Slava’s BuddyPress newsletter. @slaffik

    Go to the last entry on this thread:
    https://buddypress.org/support/topic/buddypress-newsletter-relaunched/.

    In the newsletter, see this item Disable BuddyPress Components Conditionally.


    cl0ne
    Participant

    @cl0ne

    Hi shanebp!

    Thank you for prompt reply and the resource. I tried the code as it is to see if it will disable the “friends” component for Subscribers. Unfortunately, nothing happened. In fact, the first time I tried it, I got the white screen of death. This was I believe due to the fact that I have chanced “friends” to “matches” using the language files. I popped in “matches” instead and this time I was live, but no change as far as component being disabled is concerned.

    Instead of a component, what would I need to change in the code to remove the entire activity component from say, Subscribers. I’m actually going to be applying this so a custom role.

    
    function buddydev_conditionally_disable_components( $enabled, $component ) {
     
        if ( ! is_user_logged_in() )  {
            return $enabled; // we do not disable component for the logged in user
        }
     
        $user = wp_get_current_user();
     
        $roles = $user->roles ;
        // $role check for 'subscriber', 'contributor',  'author', 'editor', 'administrator'
     
        if ( 'friends' == $component && in_array( 'subscriber', $roles ) ) {
            //disable friends for subscribers
            $enabled = false;
        }
     
        return $enabled;
    }
    add_filter( 'bp_is_active', 'buddydev_conditionally_disable_components', 10, 2 );
    

    Thanks for all your help!

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