Search Results for 'bp_after_has_activities_parse_args'
-
Search Results
-
function my_bp_activities_include_activity_types( $retval ) { // only allow the following activity types to be shown $retval['action'] = array( 'activity_update', //'activity_comment', 'new_blog_post', //'new_blog_comment', //'friendship_created', //'created_group', ); return $retval; } add_filter( 'bp_after_has_activities_parse_args', 'my_bp_activities_include_activity_types' );
This is what is suggested around the forums, but as soon as this is added, the filter by options stop working.
Same goes for bp_after_has_activities_parse_args when setting parameters for followers/freinds only. Is there something missing?
Hi all
After a lot of searching around I found a solution for a friends only activity stream.
The following function works and I am only seeing updates from friends:
function buddydev_friends_only_activity_args( $args ) { if( ! bp_is_activity_directory() || ! is_user_logged_in() ) { return $args; } $user_id = get_current_user_id(); $user_ids = friends_get_friend_user_ids( $user_id ); //include users own too? array_push( $user_ids, $user_id ); $args['user_id'] = $user_ids; //print_r($args); return $args; } add_filter( 'bp_after_has_activities_parse_args', 'buddydev_friends_only_activity_args' );
However, the mentions tab on my activity stream now displays the message “Sorry, there was no activity found.” If I remove the function I can see all the mentions again.
Mentions are still working fine on user profiles.
Any ideas what is causing this?
WordPress 5.2.2
BuddyPress 4.4.0function my_bp_activities_include_activity_types( $retval ) { // only allow the following activity types to be shown $retval['action'] = array( 'activity_update', //'activity_comment', 'new_blog_post', //'new_blog_comment', //'friendship_created', //'created_group', ); return $retval; } add_filter( 'bp_after_has_activities_parse_args', 'my_bp_activities_include_activity_types' );
This is what is suggested around the forums, but as soon as this is added, the filter by options stop working.
Same goes for bp_after_has_activities_parse_args when setting parameters for followers/freinds only. Is there something missing?
I did not develop, but help support, the http://www.EmbraceCreatives.com website. I have stumbled across three issues with the site, but I believe all are closely related.
Issue 1: The default settings for the News Feed are too inclusive and the News Feed gets clogged with uninteresting stuff. To address this issue, I received some help form this forum which resulted in my adding the following code to …/wp-content/themes/social-portfolio/functions.php. (Yes, this does belong in social-portfolio-child, but when I added it there, it did not function. It would require too much time and effort to address fix this problem, which just means that I have to be careful should we update the theme.)
function ec_filter_activity( $activity_object ) { $activity_object['action'] = array( 'item1', 'item2'); return $activity_object; } add_filter( 'bp_after_has_activities_parse_args', 'ec_filter_activity');
The good news is that this code does limit the items shown in the News Feed to those in the item list. However, the dropdown filter, which allows filtering by activity type, no longer functions. Selecting any value causes the page to refresh, but the items displayed are not changed. Also note that removing the code shown in Issue 2 below does not change this behavior.
Issue 2: Part of the customization is to allow site members to post portfolios of their work. This was implemented as a custom component called gallery and there are two activities associated with this component. The first thing I did was register these activities (as the developer had failed to do so). Next, I added the following code to …/wp-content/plugins/embrace-creatives/include/components/gallery/gallery-component.php
function setup_actions() { /*other lines from this function omitted for clarity */ add_action( 'bp_activity_filter_options', array( $this, 'display_activity_actions' ) ); /* added */ } public function display_activity_actions() { /* newly added function */ ?> <option value="<?php echo 'portfolio_published'; ?>"><?php _e('Portfolio Published'); ?></option> <option value="<?php echo 'project_published'; ?>"><?php _e('Project Published'); ?></option> <?php }
The good news is that these two actions are shown in the dropdown mentioned above. However, whereas the dropdown functions properly with regard to all other activities, it does not function for these two newly added ones (when this code is active and the code from Issue 1 is disabled).
Issue 3: The list of activities shown in the dropdown filter should match the list specified under Issue 1. While I think that I may have figured out how to add activities to this filter (see Issue 2), I do not know how to remove ones on the list, or better yet, simply specify only the ones that should be included.
We would truly appreciate any assistance you can provide. I would be more than willing to jump onto a phone call or even provide access to our clone site if someone wants to jump in.
Using ‘bp_after_has_activities_parse_args’, I am trying to create a post scheduler on buddypress (Will be glad if there’s an existing one) where if the publish date is greater than the date today, it will not show on the user who is viewing the profile. On the ‘bp_after_has_activities_parse_args’ filter, I saw a value that says ‘date_query’ I’m not sure if it’s the one I’m looking for. Do you have any idea how can I do this? Much appreciated if someone can help me since I’m new to Buddypress.
Topic: Filtering Activity Feed
I would like to prevent certain types of activities from appearing in the global feed. I have found a number of articles that discuss this, but many are quite old (prior versions) and (to a novice), many seem to be incomplete.
Based on my reading, it seems that the clean way to do this is to add some code to the file functions.php in themes/child-theme. Based on my reading, and just for testing purposes, I added the following code:
function ec_filter_activity( $activity_object ) { $activity_object['action'] = array( 'activity_comment' , 'activity_update'); $activity_object['per_page'] = 8; return $activity_object; } add_action( 'bp_after_has_activities_parse_args', 'ec_filter_activity');
However, when I reloaded the page with the activity feed, the following appeared in debug.log:
PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘ec_filter_activity’ not found or invalid function name in /var/www/html/wp-includes/class-wp-hook.php on line 286
Can you please help me figure out what I am doing wrong. I suspect that if I can get past this error, I can make the filtering work…
Thanks
I have the following code in my functions.php file
add_filter( 'bp_after_has_activities_parse_args', function( $retval ) { $retval['action'] = array( 'activity_update', 'activity_comment', 'friendship_created', 'rtmedia_update', 'new_member', 'created_group', 'joined_group', ); return $retval; } );
It works great… BUT when I try to filter the buddypress stream everything appears. There is no filtering ability. Is this the right function to use?
Dear @danbp,
I have seen and tried the solution you kindly provided at: “I am trying to remove activity comments as separate entries” on: https://buddypress.org/support/topic/i-am-trying-to-remove-activity-comments-as-separate-entries/
function my_bp_activities_include_activity_types( $retval ) { // only allow the following activity types to be shown $retval['action'] = array( // 'activity_update', 'activity_comment', 'new_blog_post', 'new_blog_comment', 'friendship_created', 'created_group', ); return $retval; } add_filter( 'bp_after_has_activities_parse_args', 'my_bp_activities_include_activity_types' );
This is awesome, until I found out that it also removes them in @-mentions – the …/activity/mentions/ posts … please, is there any way I can keep those under …/activity/mentions/ ??
Thanks a lot :))
Topic: Use several filter arguments
Hello,
I’ve a question on filter activity items. I’ve found that I can filter on for example user_id and then give several ids, and at the same time give a object as for example “groups”. This filter is now applied that it only shows the ids AND object “groups”. Is there anyway to use like the union instead. So the ids OR “groups”?
The code I use:
function friends_only_activity_args( $args ) { if( ! bp_is_activity_directory() || ! is_user_logged_in() ) { return $args; } $user_id = get_current_user_id(); $user_ids = friends_get_friend_user_ids( $user_id ); //include users own too? array_push( $user_ids, $user_id ); $args['user_id'] = $user_ids; $args['object'] = 'groups'; //print_r($args); return $args; } add_filter( 'bp_after_has_activities_parse_args', 'friends_only_activity_args' );
Thanks for any suggestion!