BuddyPress hack: Disable activity stream comments for non-friends and non-groups

What else could you do with this simple my_is_friend_check function?

How about removing the ability to Reply/Comment on non-friend and non-group activity updates.

See our previous: #BuddyPress hack: disable activity stream comments/favorites for certain types

so in the activity loop for activity-meta comment link, add the following check:

( bp_get_activity_user_id() != 0 && my_is_friend_check( bp_get_activity_user_id() ) )

what about disabling the reply comment for non-member groups?

(bp_get_activity_object_name() == 'groups' && groups_is_user_member( bp_loggedin_user_id(), bp_get_activity_item_id() ) )

So what does my if statement look like for activity-meta commenting?

if ( is_user_logged_in() && bp_activity_can_comment() &&
!my_denied_activity_meta_check( bp_get_activity_type() ) &&
( (bp_get_activity_object_name() == 'groups' && groups_is_user_member( bp_loggedin_user_id(), bp_get_activity_item_id() ) ) ||
( bp_get_activity_user_id() != 0 && my_is_friend_check( bp_get_activity_user_id() ) ) )     ) { ?>
<a href="<?php bp_activity_comment_link() ?>" id="acomment-comment-<?php bp_activity_id() ?>"><?php _e( 'Reply', 'buddypress' ) ?> (<span><?php bp_activity_comment_count() ?></span>)</a>
<?php } ?>

1) Deny all replies for certain activity types (my_denied_activity_meta_check – see previous example)
2) Allow if loggedin user is in the same group as user who made activity updates (groups_is_user_member)
3) Allow if loggedin user is a friend (my_is_friend_check – see previous example)
4*) Allow if a friend posts in a public group in which loggedin user is not a member of

(a core filter would be excellent in this case – especially if a plugin wanted to control the activity meta features.)

…think i am done with my own tweaks to the activity stream. next up members and profile pages.

Please note – these little hacks to the activity stream will increase the number of db queries.

Before (on shared host):
This page generated in 0.864 seconds, using 151 queries.

After (on shared host):
This page generated in 0.853 seconds, using 215 queries.

This entry was posted in Tech and tagged , . Bookmark the permalink.

Leave a Reply