Tagged: Buddy Press, hide admin
Hi Brajesh,
I got this code from your site but need advise on where to place it:
add_action(“plugins_loaded”,”bpdev_init_sm_mode”);
function bpdev_init_sm_mode(){
if(is_super_admin())
remove_action(“wp_head”,”bp_core_record_activity”);//id SM is on, remove the record activity hook
}Would appreciate your feedback.
Have a great weekend!
Best regards
EdwardHi Edward,
The code does not remove admin’s activity from activity stream. It only disables the recording of “last activity time” of a user.Regards
BrajeshHi Brajesh,
This is the correct code and its worked perfectly when placed in themes functions.php:
/**
* Exclude Users from BuddyPress Members List by WordPress role.
*
* @param array $args args.
*
* @return array
*/
function buddydev_exclude_users_by_role( $args ) {
// do not exclude in admin.
if ( is_admin() && ! defined( ‘DOING_AJAX’ ) ) {
return $args;
}$excluded = isset( $args[‘exclude’] ) ? $args[‘exclude’] : array();
if ( ! is_array( $excluded ) ) {
$excluded = explode( ‘,’, $excluded );
}$role = ‘administrator’;// change to the role to be excluded.
$user_ids = get_users( array( ‘role’ => $role, ‘fields’ => ‘ID’ ) );$excluded = array_merge( $excluded, $user_ids );
$args[‘exclude’] = $excluded;
return $args;
}add_filter( ‘bp_after_has_members_parse_args’, ‘buddydev_exclude_users_by_role’ );
Thank you Edward,
For others looking for the same,
The code is from the blog post. Please see the post for details.
https://buddydev.com/hiding-users-on-buddypress-based-site/Regards
Brajesh
The topic ‘ [Resolved] Hiding Admin from activity stream, Recently Active Members widget etc’ is closed to new replies.