Is it possible to hide or remove activity in the main activity stream from certain groups while keep
-
Hello, I need to know if it is possible to hide or remove activity in the main activity stream from certain groups while keeping them set as public groups? If you want an in-context look, my site is http://sunday-fundays.com. I need the home page to show activity from all groups except two. Each group in the site is for one major metro area in the United States. However, I have two groups called “Failed Sundays” & “Question of the Day” that I would like to hide from the main activity feed on the home page. I still need these groups to be public so people can join & rejoin them as they please.
Any ideas?
-
*bump*
*bump again*
It works very similar to WP post loop.
https://codex.buddypress.org/developer-docs/custom-buddypress-loops/the-groups-loop/
while ( bp_groups() ) : bp_the_group(); if(bp_get_group_name() != ‘MyGroup’ ) :
oh wait, silly me was showing you the groups loop.
https://codex.buddypress.org/developer-docs/custom-buddypress-loops/the-activity-stream-loop/
Hello modemlooper,
Thanks for your response. I still can’t quite get it to work though. I am not very good with PHP yet, so I assume it is my terrible coding. Here is how I tried to incorporate it into /buddypress/bp-themes/bp-default/activity/activity-loop.php:
What am I doing wrong? Am I even in the right file?
Sorry for being such a noob…..
while ( bp_activities() ) : bp_the_activity();
if(bp_get_group_name() != ‘Failed Sundays’ )
include( locate_template( array( ‘activity/entry.php’ ), false ) )
endif;
endwhile;What am I doing wrong?
Hello modemlooper,
Thanks for your response. I still can’t quite get it to work though. I am not very good with PHP yet, so I assume it is my terrible coding. Here is how I tried to incorporate it into /buddypress/bp-themes/bp-default/activity/activity-loop.php:
while ( bp_activities() ) : bp_the_activity();
if(bp_get_group_name() != ‘Failed Sundays’ )
include( locate_template( array( ‘activity/entry.php’ ), false ) )
endif;
endwhile;What am I doing wrong? Am I even in the right file?
Sorry for being such a noob…..
Ok, so I finally got the code to do something without breaking the site, but it did the opposite of what I need. It still shows the posts on the home page for the group that I’m trying to hide, but the activity stream for that group no longer shows those posts…lol. I need the home page to hide those posts and the group activity stream for that group to show it’s own posts.
The code I used is as follows:
‘
‘
It is located in the file /buddypress/bp-themes/bp-default/activity/activity-loop.php. I am guessing I’m just working in the wrong file. Can anyone help me find where I need to insert this code (if it is even right)?
Ok, so I definitely typed code in those back ticks from the post above, but it didn’t show up. The code without the php tags surrounding it is:
while ( bp_activities() ) : bp_the_activity();
if(bp_get_group_name() != ‘Failed SundayS’ ) :
include( locate_template( array( ‘activity/entry.php’ ), false ) )
endif;
endwhile;Maybe someone else can suggest something. I’m not sure you can exclude something that specific in the activity loop.
I tried this code but it doesn’t exclude a specific group just each content type
`function bp_my_activity_filter( $a, $activities ) {
global $bp;if ( $bp->current_component != $bp->activity->slug )
return $activities;foreach( $activities->activities as $key => $activity ) {
if ( $activity->type ==’new_forum_topic’ ) {
unset( $activities->activities[$key] );
$activities->total_activity_count = $activities->total_activity_count – 1;
$activities->activity_count = $activities->activity_count – 1;
}
}$activities_new = array_values( $activities->activities );
$activities->activities = $activities_new;
return $activities;
}
add_action( ‘bp_has_activities’, ‘bp_my_activity_filter’, 10, 2 );`Hmm getting somewhere…..
if ( $activity->type ==’activity_update’ && $activity->item_id == ’34’ ) {
the item_id number is the id of the group.
oh the code above should be placed in a file bp-custom.php in the plugins folder
Hey,
I tried the following code from your post above, but it still isn’t working. The activity from the group I’m trying to hide is still showing up on the home page.
‘
function bp_my_activity_filter( $a, $activities ) {
global $bp;if ( $bp->current_component != $bp->activity->slug )
return $activities;foreach( $activities->activities as $key => $activity ) {
if ( $activity->type ==’activity_update’ && $activity->item_id == ‘131’ ) {
unset( $activities->activities[$key] );
$activities->total_activity_count = $activities->total_activity_count – 1;
$activities->activity_count = $activities->activity_count – 1;
}
}$activities_new = array_values( $activities->activities );
$activities->activities = $activities_new;
return $activities;
}
add_action( ‘bp_has_activities’, ‘bp_my_activity_filter’, 10, 2 );
‘I added the new file /wp-content/plugins/bp-custom.php. I got the group id by adding bp_group_id() into groups-loop.php which is 131 as dictated in the code above. I did a test and removed the first if statement, and it removed all of the activity on that group’s page successfully. Everything from that group was still visible on the home page though.
By the way, thank you soooo much for helping me with this. I am totally lost on this thing.
Just realized that the code above works on an individual user’s activity stream (e.g. …/members/*username*/activity/groups/). It hides the activity from the group I want to hide, but I don’t want to hide it from here. I actually do want it to show up in the user’s activity stream, but not on the home page where all activity is displayed from every public group.
Try something like this:
if ( $bp->current_component != $bp->activity->slug || $bp->current_component == $bp->members->slug )
No such luck.
I replaced
`if ( $bp->current_component != $bp->activity->slug )`
with
`if ( $bp->current_component != $bp->activity->slug || $bp->current_component == $bp->members->slug )`
and the individual user activity still doesn’t show the activity from the selected groups.More importantly though, the content I’m trying to hide is still showing up on the home page. It is only being hidden from the individual user’s activity.
The loop has never been easy to pick out individual items. The filtering is mainly for type AND to top it off the user activity stream is the same stream as the sitewide just filtered to an individual
Maybe someone else can suggest a way.
Well, thank you anyway for trying. Does anyone else have any ideas?
The code I provided is a way to go but you need to figure out the correct if statement to make it work on sitewide activity and not a user profile.
test
I have been trying a bunch of stuff, but I’m not even sure if I’m doing it right. Does this look right to you?
if ( $bp->current_component != $bp->activity->slug || $bp->current_component != $bp->members->slug || is_null($bp->current_component) )
On the home page the value of $bp->current_component is NULL.
has there been any progress with this? im trying to filter out ‘ALL’ group activity from the site-wide feed so that groups can finally post vids and pics without cluttering the site-wide feed which i need to make specialized for specific posts only.
headz up would be wicked
- The topic ‘Is it possible to hide or remove activity in the main activity stream from certain groups while keep’ is closed to new replies.