Search Results for 'bp_after_has_activities_parse_args'
-
AuthorSearch Results
-
November 9, 2023 at 7:44 pm #331880
teeboy4real
ParticipantI had the option Allow activity stream commenting on posts and comments disabled I also have some code in custom.php file. I am not sure if it could have any effect
/* Disable comment for all activity but still enable @mention autosuggestion. */ function disable_activity_comments($can_comment, $activity) { // Disable comments $can_comment = false; return $can_comment; } add_filter('bp_activity_can_comment', 'disable_activity_comments', 10, 2); /* Hide comment from activity page */ add_action( 'bp_after_has_activities_parse_args', function ( $r ) { if ( bp_is_activity_directory() || bp_is_single_activity() ) { $r['display_comments'] = false; } return $r; } ); // Exclude activity updates from subscribers who are not logged in on the activity directory page. function hide_new_member_activities_from_unlogged_users( $args ) { if ( ! is_user_logged_in() ) { $args['action'] = array( 'activity_comment', 'activity_update', 'last_activity', 'new_avatar', 'new_blog_comment', 'new_blog_post', 'new_classified', 'updated_profile' ); } return $args; } add_filter( 'bp_after_has_activities_parse_args', 'hide_new_member_activities_from_unlogged_users' );June 6, 2020 at 2:34 pm #312216In reply to: Limit activity stream only to self
Prashant Singh
Participantfunction ps_mine_activity_args( $args ) { if ( ! bp_is_activity_directory() || ! is_user_logged_in() || ! empty( $args['scope'] ) ) { return $args; } $user_id = get_current_user_id(); $args['user_id'] = $user_id; return $args; } add_filter( 'bp_after_has_activities_parse_args', 'ps_mine_activity_args' );Please put the above given code in your bp-custom.php file or in your child theme’s functions.php file.
Hope that it will show only logged-in user’s activities in the sitewide activity stream.
March 9, 2020 at 9:44 am #310415jeeve94
Participantfunction 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?
August 21, 2019 at 10:32 am #307463kobrakai75
ParticipantHi 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.0June 26, 2019 at 11:40 pm #306721In reply to: Filter the Activity Loop for Specific User Updates
colingdi
ParticipantThat helped a lot, I’ve now got it filtering for the users activity on just their profile page. So we’re halfway there. Using your links I’m to the point where I have this code:
function my_filter_after_has_activities_parse_args( $r ) { $r['per_page'] = 10; if (bp_is_my_profile()) { $r['per_page'] = 3; $r['scope'] = "just-me"; } else if (bp_is_user_profile()) { $r['per_page'] = 3; //$r['scope'] = "just-me"; - I'll work out the code for just-them after I get the function calling } return $r; } add_filter( 'bp_after_has_activities_parse_args', 'my_filter_after_has_activities_parse_args' );When I run this code on a normal users profile I get nothing changed (the final bp_is_user_profile() doesn’t fire). I’m on the site.com/members/user page and it’s the ‘home.php’ template that’s calling all of this so I’m at a loss as to why I’m getting no joy.
June 25, 2019 at 7:33 pm #306698In reply to: Filter the Activity Loop for Specific User Updates
Henry Wright
ModeratorTry using
bp_parse_args(). Here is an example:function my_filter_after_has_activities_parse_args( $r ) { $r['per_page'] = 3; // Do something else here return $r; } add_filter( 'bp_after_has_activities_parse_args', 'my_filter_after_has_activities_parse_args' );See https://codex.buddypress.org/developer/using-bp_parse_args-to-filter-buddypress-template-loops/
May 27, 2019 at 5:48 pm #306189Nahum
Participantfunction 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?
May 17, 2019 at 2:35 pm #305947In reply to: Search / Filter Activity by Meta
btees
ParticipantGot it sorted.
I set up a new search-form.php in my child theme:
<div class="<?php bp_nouveau_search_container_class(); ?> bp-search" data-bp-search="<?php bp_nouveau_search_object_data_attr() ;?>"> <form action="" method="get" class="bp-dir-search-form" id="<?php bp_nouveau_search_selector_id( 'search-form' ); ?>"> <select onchange="this.form.submit()" id="<?php bp_nouveau_search_selector_id( 'search' ); ?>" name="<?php bp_nouveau_search_selector_name(); ?>"> <option value="" disabled selected>Filter by Industry</option> <option value="">All</option> <?php $result = $wpdb->get_results ( "SELECT * FROM wp_bp_xprofile_fields WHERE id='2'" ); foreach ( $result as $print ); $options = $wpdb->get_results ( "SELECT * FROM wp_bp_xprofile_fields WHERE parent_id='$print->id'" ); foreach ( $options as $option ) { ;?> <option class="<?php echo $option->name;?>" name ="field_<?php echo $print->id;?>_match_any[]"value="<?php echo $option->name;?>"><?php echo $option->name;?></option> <?php } ;?> </select> </form> </div>And then Ravi over at BuddyDev figured out how to change what the search applies to:
// Activity Search by Category function buddydev_filter_activities_query_args( $r ) { $searched_category = empty( $r[ 'search_terms' ] ) ? false : $r[ 'search_terms' ]; if ( ! $searched_category ) { return $r; } $r['search_terms'] = false; if ( empty( $r['meta_query'] ) ) { $r['meta_query'] = array( array( 'key' => 'bpcat', 'value' => $searched_category, ) ); } else { array_push( $r['meta_query'], array( 'key' => 'bpcat', 'value' => $searched_category, ) ); } return $r; } add_filter( 'bp_after_has_activities_parse_args', 'buddydev_filter_activities_query_args' );February 17, 2019 at 4:53 pm #302927In reply to: filter activity stream re friends
mrjanvier
ParticipantDear,
I tried but it didn’t work. I made a bp-custom.php map in: wp-content/plugins/bp-custom.php –> In the map bp-custom.php i placed a file bp-custom.php
I used notedpadd ++ as a editor to place the code you give me and copied it to my server. Once installed, i can’t enter my site. It gives an error:
Warning: require …
Fatal error: require(): Failed opening .. class-buddypress.php on line 226This looks strange, cause the code filled in notepadd ++ goes only to line 11.
I filled it in as:
<?php
function bp_activities_user_friends_scope( $retval ) {if ( bp_is_activity_directory() ) {
$retval[‘scope’] = ‘friends’;
}return $retval;
}
add_filter( ‘bp_after_has_activities_parse_args’, ‘bp_activities_user_friends_scope’ );
?>did I do something wrong?
Big thank for youre help
February 10, 2019 at 7:16 pm #302754In reply to: filter activity stream re friends
shanebp
ModeratorYou can use the
scopeargument for that.
Try this in your theme > functions.php or in bp-custom.phpfunction bp_activities_user_friends_scope( $retval ) { if ( bp_is_activity_directory() ) { $retval['scope'] = 'friends'; } return $retval; } add_filter( 'bp_after_has_activities_parse_args', 'bp_activities_user_friends_scope' );July 22, 2018 at 3:56 pm #275382In reply to: Filtering Activity Feed
groston
Participantr-a-y,
This is blather to try to trick the ‘Duplicate reply detected’ nonsense.
Thanks for the reply – seem like the right approach, but… Following is my code:
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');When I load the activity feed, I get this warning (in the debug.log file):
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 286I do not understand why this error is appearing – can you offer some guidance?
p.s. The site is the MVP for the company. If there is decent adoption, the next release will be a custom app, so moving the code into a plugin is not really needed.
March 8, 2018 at 2:58 pm #271229In reply to: Activities
HDcms
ParticipantHello @danbp
PHP Warning: Illegal offset type in /home…./wp-content/plugins/buddypress/bp-activity/bp-activity-functions.php on line 734I found where the error came from:
add_filter( 'bp_after_has_activities_parse_args', 'activites_affiche_infos' ); function activites_affiche_infos( $retval ) { // if ( bp_is_active( 'activity' ) ) { $retval['action'] = array( 'activity_comment', 'activity_update', //'created_group', //'friendship_created', 'joined_group', 'last_activity', //'new_avatar', 'new_blog_comment', 'new_blog_post', //'new_member', 'updated_profile' ); return $retval; // } }I feel that this function does not work anymore with the latest version of buddypress. If I disable it, => all works
I activate it by trying several solutions and nothing else works !!
I tried your code without success either@ +
An “old” member of your BP siteMarch 6, 2018 at 1:42 pm #271202In reply to: php warning: bp-activity-function
HDcms
ParticipantHi,
I feel that this function does not work anymore with the latest version of buddypress. If I disable it, => all works
I activate it by trying several solutions and nothing else works !!add_filter( 'bp_after_has_activities_parse_args', 'activites_affiche_infos' ); function activites_affiche_infos( $retval ) { // if ( bp_is_active( 'activity' ) ) { $retval['action'] = array( 'activity_comment', 'activity_update', //'created_group', //'friendship_created', 'joined_group', 'last_activity', //'new_avatar', 'new_blog_comment', 'new_blog_post', //'new_member', 'updated_profile' ); return $retval; // } }March 1, 2018 at 3:05 pm #271134In reply to: php warning: bp-activity-function
HDcms
ParticipantHello
[17-Feb-2018 11:37:41 UTC] PHP Warning: Illegal offset type in /home…./wp-content/plugins/buddypress/bp-activity/bp-activity-functions.php on line 734I found where the error came from:
add_filter( 'bp_after_has_activities_parse_args', 'activites_affiche_infos' ); function activites_affiche_infos( $retval ) { $retval['action'] = array( 'activity_comment', 'activity_update', 'created_group', 'friendship_created', //nouv relation entre membre 'joined_group', 'last_activity', 'new_avatar', 'new_blog_comment', 'new_blog_post', //'new_member', 'updated_profile', 'rtmedia_update' // ajout important sinon on perd l'affichage des médiaq ); return $retval; }IF you can tell me the mistake !?
For the other, it’s the mailster plugin
[24-Feb-2018 00:59:35 UTC] PHP Warning: mysqli_query(): Error reading result set's header in /home/../wp-includes/wp-db.php on line 1924 [24-Feb-2018 01:56:20 UTC] PHP Warning: mysqli_query(): MySQL server has gone away in /home/../wp-includes/wp-db.php on line 1924June 29, 2017 at 4:56 pm #266780In reply to: reorder the activities in activity stream
Henry Wright
ModeratorTry this:
add_filter( 'bp_after_has_activities_parse_args', function( $retval ) { $retval['display_comments'] = 'stream'; return $retval; } );Please note I haven’t tested.
June 21, 2017 at 3:56 pm #266609In reply to: Hiding admins activity and profile errors
slimmyweight
ParticipantHi Henry,
Thanks for the reply,
I’m not a programmer I have basic programming knowledge at best. I’ve tried pasting
// Fetch only the last five entries for all activity loops function my_bp_activities_per_page_5( $retval ) { $retval['per_page'] = 5; return $retval; } add_filter( 'bp_after_has_activities_parse_args', 'my_bp_activities_per_page_5' );at the top of my current code and it is still the same showing an fatal error message and allowing me to view the admins profile.
Have I put the code in the wrong place, or is it even possible for me to comprehend what I need to do without knowing php?
Thanks
June 21, 2017 at 3:04 pm #266608In reply to: Hiding admins activity and profile errors
Henry Wright
ModeratorI recommend using the
bp_after_has_activities_parse_argsfilter to modify the activity stream (remove admin items). Check out this helpful article:June 15, 2017 at 7:15 am #266521kodacollider
ParticipantI had to disable activity update comments from displaying as their own items entirely to fix this, but it looks like doing so did. I used the code from this thread.
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' );Weird issue all around.
November 1, 2016 at 5:09 pm #260610In reply to: Site Wide Activity Stream
tronix-ex
Participant@danbp thanks for your response I’ve used the below code as per the suggested link but still it dosen’t work.
function my_bp_activities_per_page_5_on_user_activity( $retval ) { // only fetch the last five entries if we're on a user's activity page if ( bp_is_user_activity() ) { $retval['action'] = 'bbp_reply_create, bbp_topic_create, activity_update'; $retval['object'] = 'profile, status'; } return $retval; } add_filter( 'bp_after_has_activities_parse_args', 'my_bp_activities_per_page_5_on_user_activity' );October 25, 2016 at 5:03 pm #260312In reply to: Activities
danbp
ParticipantHi @mei-ling,
it’s not an issue but how it works ! 😉
You can filter the activity stream and remove the activities you don’t want to be showed.
Add this snippet to bp-custom.php or your child-theme functions.php
function bpex_bp_activity_types( $retval ) { if ( bp_is_active( 'activity' ) ) { // list of all BP activity types - remove or comment those you won't show. $retval['action'] = ' activity_comment, activity_update, // bbp_topic_create, // bbp_reply_create, friendship_created, created_group, joined_group, last_activity, new_avatar, new_blog_post, new_blog_comment, new_member, updated_profile '; return $retval; } } add_filter( 'bp_after_has_activities_parse_args', 'bpex_bp_activity_types' );You might also remove bbpress activities from the activity filter. You can use this (goes to same file as previous)
function bpex_remove_bbp_activities_dropdown_labels() { if ( bp_is_active( 'activity' ) ) { // Remove forum filters in site wide activity streams remove_action( 'bp_activity_filter_options', array( bbpress()->extend->buddypress->activity , 'activity_filter_options' ), 10 ); // Remove forum filters in single member activity streams remove_action( 'bp_member_activity_filter_options', array( bbpress()->extend->buddypress->activity , 'activity_filter_options' ), 10 ); // Remove forum filters in single group activity streams remove_action( 'bp_group_activity_filter_options', array( bbpress()->extend->buddypress->activity , 'activity_filter_options' ), 10 ); } } add_action( 'bp_init', 'bpex_remove_bbp_activities_dropdown_labels', 9 );Codex references:
October 19, 2016 at 5:13 pm #260002davidtuttle
ParticipantTopic is resolved. Comments were being restricted in them folders function.php. I added check for bp_is_group_single. Current code:
//Restrict access to BP to logged-in users only
function my_filter_activity( $loop ) {// added 10/19/16 D.T. – show all comments in single group home page
if ( !bp_is_group_home() )
$loop[‘scope’] = ‘just-me,friends’;return $loop;
}
add_filter( ‘bp_after_has_activities_parse_args’, ‘my_filter_activity’ );August 31, 2016 at 7:19 pm #258221ruess
ParticipantSuper helpful and very hard to find. Just so we keep this archived (as the vital code is on a blog), I’m going to repeat it below:
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' );July 14, 2016 at 8:07 pm #256612Jeremy Pry
ParticipantThanks all for the quick replies. I don’t mean to ignore all of your helpful questions and suggestions, but those may not be needed anymore.
After getting a chance to speak with a colleague who’s been out of the office for a while, I was able to identify the problem here. A function from a custom plugin was filtering both the
bp_before_has_activities_parse_argsandbp_after_has_activities_parse_argsfilters, and the specific problem was that it was setting$args['include']to an empty string. This removed the comment ID that was supposed to be part of the query, and resulted in the wrong query. We don’t know why it was doing this in the first place, but it has been corrected and the infinite loop has been fixed.Regardless, it may be beneficial to include some checking in this code to prevent the possibility of an infinite loop even for edge cases like this.
June 18, 2016 at 9:33 pm #254815In reply to: Activity updates only available to friends
Jonas
Participantlike Henry mentioned, you can use the bp_parse_args. You could do the following to achieve it:
// Activity stream -> friends only
function my_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 ); array_push( $user_ids, $user_id ); $args['user_id'] = $user_ids; return $args; } add_filter( 'bp_after_has_activities_parse_args', 'my_friends_only_activity_args' );May 20, 2016 at 2:11 pm #253585In reply to: Not show all activity
danbp
ParticipantPlease read first BP’s documentation:
Many topics with same question where already resolved.
https://buddypress.org/support/search/bp_after_has_activities_parse_args/ -
AuthorSearch Results