BuddyDev

Search

Replies

  • Participant
    Level: Initiated
    Posts: 4
    gavyn on #53541

    I ended up figuring it out. Thank you for the help.

  • Participant
    Level: Initiated
    Posts: 4
    gavyn on #53540

    This code is not working. when i try going into a group now, it just shows “loading the group updates. PLease wait.”

    I want everyone to be able to still see updates but only group admins can post them.

  • Participant
    Level: Initiated
    Posts: 4
    gavyn on #53512

    for groups which if you could please help with code

  • Participant
    Level: Initiated
    Posts: 4
    gavyn on #53511
     function restrict_activity_updates_to_admins( $activity_content ) {
        // Check if the current user is logged in
        if ( is_user_logged_in() ) {
            // Get the current user's roles
            $user = wp_get_current_user();
            $roles = $user->roles;
    
            // Allow administrators to post updates
            if ( in_array( 'administrator', $roles ) ) {
                return $activity_content; // Admins can post
            } else {
                // Block non-admins from posting
                bp_core_add_message( __( 'Only administrators can post activity updates.', 'buddypress' ), 'error' );
                bp_core_redirect( wp_get_referer() ? wp_get_referer() : home_url() );
                return false;
            }
        }
    
        return $activity_content;
    }
    add_filter( 'bp_activity_content_before_save', 'restrict_activity_updates_to_admins' ); 

    This is my code to limit access to posting for admins only. I just want to make it so that the post forum doesn’t even show up for non admns.