Replies
Viewing 4 posts - 1 through 4 (of 4 total)
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.
Viewing 4 posts - 1 through 4 (of 4 total)