Skip to content

Instantly share code, notes, and snippets.

@raftaar1191
Created September 5, 2023 15:46
Show Gist options
  • Save raftaar1191/83b1da0be2db8f495259e02345a26185 to your computer and use it in GitHub Desktop.
Save raftaar1191/83b1da0be2db8f495259e02345a26185 to your computer and use it in GitHub Desktop.
Fix BuddyBoss Platform V 2.4.11 Activity issue
/**
* Remove the new filter that is been added into BuddyPress 2.4.11
*/
function awp_bp_init_bb_platform_issue() {
remove_filter( 'bp_activity_set_just-me_scope_args', 'bp_activity_filter_just_me_scope', 10 );
}
add_action( 'bp_init', 'awp_bp_init_bb_platform_issue' );
/**
* Set up activity arguments for use with the 'just-me' scope.
*
* @since BuddyPress 2.2.0
*
* @param array $retval Empty array by default.
* @param array $filter Current activity arguments.
* @return array $retval
*/
function awp_bp_activity_filter_just_me_scope( $retval = array(), $filter = array() ) {
// Determine the user_id.
if ( ! empty( $filter['user_id'] ) ) {
$user_id = $filter['user_id'];
} else {
$user_id = bp_displayed_user_id()
? bp_displayed_user_id()
: bp_loggedin_user_id();
}
// Should we show all items regardless of sitewide visibility?
$show_hidden = array();
if ( ! empty( $user_id ) && $user_id !== bp_loggedin_user_id() ) {
$show_hidden = array(
'column' => 'hide_sitewide',
'value' => 0,
);
}
$privacy = array( 'public' );
if ( is_user_logged_in() ) {
$privacy[] = 'loggedin';
if ( bp_is_active( 'friends' ) ) {
// Determine friends of user.
$friends = friends_get_friend_user_ids( $user_id );
if ( $user_id === bp_loggedin_user_id() || bp_is_activity_directory() ) {
$friends[] = bp_loggedin_user_id();
}
if ( ! empty( $friends ) && in_array( bp_loggedin_user_id(), $friends ) ) {
$privacy[] = 'friends';
}
}
if ( $user_id === bp_loggedin_user_id() ) {
$privacy[] = 'onlyme';
}
}
$retval = array(
'relation' => 'AND',
array(
'column' => 'user_id',
'value' => $user_id,
),
array(
'column' => 'privacy',
'value' => $privacy,
'compare' => 'IN',
),
$show_hidden,
// Overrides.
'override' => array(
// 'display_comments' => bp_show_streamed_activity_comment() ? 'stream' : 'threaded',
'filter' => array( 'user_id' => 0 ),
'show_hidden' => true,
),
);
return $retval;
}
add_filter( 'bp_activity_set_just-me_scope_args', 'awp_bp_activity_filter_just_me_scope', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment