Hi guys,
I’m trying to create code to allow my website users to be excluded from the sitewide activity stream, per user id.
They simply request to admin to be excluded and I add their user id to the $exclude array and that’s it. A bit crude, but simple and it works.
But there is an issue with one type of activity, the one which shows in the activity stream as “UserA and UserB are now friends x-time ago”
My code correctly excludes this activity if the initiator of the friendship request is in my array.
But I require this activity to be excluded also if the “accepter” is in the array.
So if the initiator OR the accepter is in the array then the activity should be hidden (sitewide).
Could you assist please?
My code is below.
`
function do_not_display_sitewide( $activity_object ) {// array of user IDs
$exclude = array( 1, 2, 3 );if( in_array( $activity_object->user_id, $exclude ) )
$activity_object->hide_sitewide = true;}
add_action(‘bp_activity_before_save’, ‘do_not_display_sitewide’, 1, 1 );So something is missing from my code.
Sorry, it pasted messy and won’t let me edit.
Here it is again.
function do_not_display_sitewide( $activity_object ) { // array of user IDs $exclude = array( 1, 2, 3 ); if( in_array( $activity_object->user_id, $exclude ) ) $activity_object->hide_sitewide = true; } add_action('bp_activity_before_save', 'do_not_display_sitewide', 1, 1 );
You must be logged in to reply to this topic.