Search Results for 'bp_after_has_activities_parse_args'
-
AuthorSearch Results
-
May 6, 2016 at 6:54 pm #253187
Night Hawk
ParticipantReally, I don’t know why, but is not working…
I add it like this in my themes faction.php
add_filter( 'bp_after_has_activities_parse_args', function( $retval ) { $retval['action'] = array( 'activity_update', 'activity_comment', 'updated_profile', ); return $retval; } );but nothing works.
May 6, 2016 at 9:25 am #253178Henry Wright
ModeratorSorry for the delay in getting back to you. So it looks like we will need to add our actions instead of removing them. Here’s where the fun part begins. You’ll need to find a list of all the action types you want in your stream and add them to the following snippet:
add_filter( 'bp_after_has_activities_parse_args', function( $retval ) { $retval['action'] = array( 'activity_update', 'activity_comment', 'another_action_here_etc', ); return $retval; } );Obviously, don’t include
updated_profileornew_avatar.May 4, 2016 at 5:32 pm #253139Henry Wright
ModeratorDo you mind doing a little debugging for me? If you paste the following code into your theme’s functions.php file (make sure this is done on your testing install). Then visit the activity stream. You should see some output dumped on the screen. Can you copy that and paste it here?
add_filter( 'bp_after_has_activities_parse_args', function( $retval ) { var_dump( $retval['action'] ); return $retval; } );May 2, 2016 at 10:57 pm #253084Night Hawk
Participantadd_filter( 'bp_after_has_activities_parse_args', function( $retval ) { // Convert $retval['action'] into an array. $parts = explode( ',', $retval['action'] ); // Remove new_avatar items. if ( ( $key = array_search( 'new_avatar', $parts ) ) !== false ) { unset( $parts[$key] ); } // Remove updated_profile. if ( ( $key = array_search( 'updated_profile', $parts ) ) !== false ) { unset( $parts[$key] ); } // Convert $parts back into a comma separated string. $retval['action'] = implode( ',', $parts ); return $retval; } );May 1, 2016 at 10:06 pm #253064Henry Wright
ModeratorTo stop “profile photo updated” updates being displayed in your activity stream, try this:
add_filter( 'bp_after_has_activities_parse_args', function( $retval ) { // Convert $retval['action'] into an array. $parts = explode( ',', $retval['action'] ); // Remove new_avatar items. if ( ( $key = array_search( 'new_avatar', $parts ) ) !== false ) { unset( $parts[$key] ); } // Convert $parts back into a comma separated string. $retval['action'] = implode( ',', $parts ); return $retval; } );Please note I haven’t tested.
April 22, 2016 at 4:59 pm #252785In reply to: Personal + Friends activity = ‘All’ activity tab?
BackpackersUnion
Participant@sharmavishal Thanks for the suggestion! “BuddyPress Wall” goes beyond what I’m looking for and seems to have quite a few unhappy users (Even most of the 5 star reviews are issues). So, I’m afraid it will cause more issues than it would solve.
I’ve found a tutorial here using
bp_parse_args()to create an activity loop with ‘Personal’ and ‘Friends Activity’ only, but not a way to isolate the loop into its own subnav tab “All” (The code currently effects all activity loops universally [i.e. Friends, Personal, Mentions, Favorites, Site wide, all become Friends+Personal loops]).Here’s the code to filter the activity loop into Friends+Personal,
function my_filter_activity( $loop ) { $loop['scope'] = 'just-me,friends'; return $loop; } add_filter( 'bp_after_has_activities_parse_args', 'my_filter_activity' );The next step would be isolating the loop into an ‘All’ activity subnav tab/button.
Any ideas?
March 17, 2016 at 10:50 am #251376Henry Wright
ModeratorI don’t have enough data set up on my local install to test, but you could try this:
add_filter( 'bp_after_has_activities_parse_args', function( $retval ) { $filter_query[] = array( 'relation' => 'OR', array( 'column' => 'content', 'value' => 'philippine tube-nosed fruit bat', 'compare' => 'LIKE' ), array( 'column' => 'content', 'value' => 'nyctimene rabori', 'compare' => 'LIKE' ) ); $filter_query[] = array( array( 'column' => 'content', 'value' => 'sea lion', 'compare' => 'NOT LIKE' ) ); $retval['filter_query'] = $filter_query; return $retval; } );March 16, 2016 at 10:26 pm #251355IdleWanderer
ParticipantI tried it, but it din’t work. At least it didn’t stop the filter rules already set up, like they did when I tried before.. So only words with lion shows up, but also sea lion.. Even with the code set up exactly like yours. Like this:
function my_bp_activities_search_term_on_page_241( $retval ) { // Add search term for correct page if ( is_page(241) ) { $filter_query[] = array( 'relation' => 'OR', array( 'column' => 'content', 'value' => 'lion', 'compare' => 'LIKE', array( 'column' => 'content', 'value' => 'sea lion', 'compare' => 'NOT LIKE' ) ), array( 'column' => 'content', 'value' => 'lion', 'compare' => 'LIKE', array( 'column' => 'content', 'value' => 'sea lion', 'compare' => 'NOT LIKE' ) ), ); $retval['filter_query'] = $filter_query; } return $retval; } add_filter( 'bp_after_has_activities_parse_args', 'my_bp_activities_search_term_on_page_241' );March 15, 2016 at 3:12 pm #251270Henry Wright
ModeratorAh, that’s not quite how to use it. You should filter inside the function you’re hooking to
bp_after_has_activities_parse_args. For example:add_filter( 'bp_after_has_activities_parse_args', function( $retval ) { $filter_query[] = array( 'relation' => 'OR', array( 'column' => 'content', 'value' => 'philippine tube-nosed fruit bat', 'compare' => 'LIKE' ), array( 'column' => 'content', 'value' => 'nyctimene rabori', 'compare' => 'LIKE' ) ); $retval['filter_query'] = $filter_query; return $retval; } );March 15, 2016 at 3:08 pm #251268IdleWanderer
ParticipantOkay, so what I tried now didn’t work, but that’s because I really do not know what I am doing. I’m just testing the waters with what I learned from the search terms and the code you just posted. I ended up having my functions.php file looking like this:
$filter_query[92] = array( 'relation' => 'OR', array( 'column' => 'content', 'value' => 'philippine tube-nosed fruit bat', 'compare' => 'LIKE' ), array( 'column' => 'content', 'value' => 'nyctimene rabori', 'compare' => 'LIKE' ) ); function my_bp_activities_search_term_on_page_92( $retval ) { // Add search term for correct page if ( is_page(92) ) { $retval['filter_query'] = $filter_query[92]; } return $retval; } add_filter( 'bp_after_has_activities_parse_args', 'my_bp_activities_search_term_on_page_92' );And that clearly did not work, so what will work?
March 15, 2016 at 12:41 pm #251250IdleWanderer
ParticipantThanks! I think I got it now!
I just added this to my functions.php:
function my_bp_activities_search_term_on_page_92( $retval ) { // Add search term for correct page if ( bp_is_page(92) ) { $retval['search_term'] = 'philippine tube-nosed fruit bat'; } return $retval; } add_filter( 'bp_after_has_activities_parse_args', 'my_bp_activities_search_term_on_page_92' );Do you think this will work? I do not have any ways to test if it actually works yet.. Another thing, how do I add multiple search terms? Everytime I tried adding another one I got an error, I tried doing this:
$retval['search_term'] = 'philippine tube-nosed fruit bat', 'philippine tube-nosed bat', 'nyctimene rabori';March 15, 2016 at 10:53 am #251246Henry Wright
ModeratorYou can add a custom function to the
bp_after_has_activities_parse_argsfilter hook like this:add_filter( 'bp_after_has_activities_parse_args', function( $retval ) { // Change search-term to your own search term. $retval['search_terms'] = 'search-term'; return $retval; } );January 19, 2016 at 9:00 pm #248867In reply to: Limit ALL activity streams to ONLY member updates
iwishiknew
ParticipantI figured it out. This will help everyone who has this question:
function omni_filter_activity( $retval ) { $retval['action'] = 'activity_update'; // change scope per action return $retval; } add_filter( 'bp_after_has_activities_parse_args', 'omni_filter_activity' );December 18, 2015 at 5:22 pm #247877Andrew
ParticipantThanks Henry. I’ve got more info on this to help the core team fix this issue.
I think all WordPress conditionals are not working correctly inside the bp_after_has_activities_parse_args filter. Only BuddyPress conditionals are working inside it.
I also have custom member pages too using bp_after_has_members_parse_args, but WordPress conditionals inside that are all working fine, example:
// filter member pages function cm_members_filter( $retval ) { if ( is_page('custom-page-3') ) { $retval['per_page'] = 1; } if ( is_page('custom-page-4') ) { $retval['per_page'] = 5; } if ( is_search() ) { $retval['per_page'] = 3; } return $retval; } add_filter( 'bp_after_has_members_parse_args', 'cm_members_filter' );It is just the activity parse args that is having problems with WordPress conditionals. I can provide further info to help figure out why WordPress conditionals don’t work correctly inside bp_after_has_activities_parse_args, it has something to do with the way ajax is used on the load more button to load more items:
If I remove activity ajax features by removing <div class=”activity”></div> or by removing bp-templates/bp-legacy/js/buddypress.min.js. The load more button now works like a pagination next page button (similar to the members directory pagination). This makes the WordPress conditionals work fine and all my custom activity pages are now filtering correctly.
So to conclude, WordPress conditionals are working OK inside bp_after_has_members_parse_args, but they are not working correctly inside bp_after_has_activities_parse_args unless the activity ajax is removed.
December 17, 2015 at 8:40 pm #247854In reply to: Trouble with custom activity function
Henry Wright
ModeratorAh OK, cool. In that case you may also be interested to hear about
bp_parse_args(). I think it’s a better way of doing what you want. This approach will also handle the loop pagination for you. For example:function my_func( $ret ) { // Your custom stuff here. return $ret; } add_filter( 'bp_after_has_activities_parse_args', 'my_func' );See the Using bp_parse_args() to filter BuddyPress template loops article for a complete guide.
November 20, 2015 at 10:33 pm #247036AM77
ParticipantThanks @r-a-y that does work for the front page, but
bp_is_component_front_page( 'activity' )or the one I just suggestedbp_is_activity_front_page()doesn’t seem to work correctly when using the activity parse args filter. The best solution I’ve got now is using! bp_is_user() && bp_is_current_component( 'activity' )This makes this work correctly:/* Display just the activity updates for who the the logged-in user is following and updates from the logged in user*/ function am_activity_filter( $retval ) { if ( ! bp_is_user() && bp_is_current_component( 'activity' ) ) { $retval['scope'] = 'following,just-me'; $retval['action'] = 'activity_update'; } return $retval; } add_filter( 'bp_after_has_activities_parse_args', 'am_activity_filter' );The problem with this conditional
bp_is_component_front_page( 'activity' )in my activity parse args filter is activity items keep showing from everyone instead of the items from who a user is following (I’m using your master follow plugin). The items that are not supposed to display, disappear when the user refreshes the page which makes the correct items display, but they keep coming back through the ‘load newest’. Have you tried this? Nevertheless! bp_is_user() && bp_is_current_component( 'activity' )is the one that is working correctly for this.October 29, 2015 at 6:03 pm #246126In reply to: Filtering Activity Loop
nicolemb
ParticipantThanks @shanebp – This is our problem. This whole solution hinges on adding meta with the blog id to EVERYTHING that could appear in an activity stream. (We also have Activity Plus Plugin active on one site and those posts seem to be missing getting the meta added)
Is there something we hook to in order to add meta to all activity? we tried
add_action('bp_activity', 'where_activity_from', 10, 3);but it’s still not adding meta to all.Or is there a better way to filter activity streams to only show activity from the current site on a multisite setup?
Here’s our latest attempt at a must-use plugin, but not all activity is shown implying the meta values are not being added:
<?php // Add Blog ID meta to activity posts add_action('bp_activity', 'where_activity_from', 10, 3); function where_activity_from($content, $user_id, $activity_id) { bp_activity_add_meta($activity_id, '_source_blog', get_current_blog_id()); } // Filter specific sites for activity from that site only function bp_after_has_activities_parse_args_func($r) { $blog_id = get_current_blog_id(); global $wpdb; $sql = $wpdb->prepare("SELECT activity_id FROM " . $wpdb->base_prefix . "bp_activity_meta WHERE meta_key=%s AND meta_value=%d", '_source_blog', $blog_id); $ids = array_values($wpdb->get_col($sql)); if (empty($ids)) { $r['in'] = '-1'; } else { $r['in'] = $ids; } return $r; } if (get_current_blog_id() !== 1) { add_filter('bp_after_has_activities_parse_args', 'bp_after_has_activities_parse_args_func'); }September 4, 2015 at 12:57 am #244036In reply to: filter activity loop
Angelo Rocha
ParticipantWorks fine with a little change:
function omni_filter_activity( $retval ) { $retval['action'] = 'bbp_reply_create,bbp_topic_create'; // change scope per action return $retval; } add_filter( 'bp_after_has_activities_parse_args', 'omni_filter_activity' );August 30, 2015 at 4:06 pm #243867In reply to: filter activity loop
shanebp
ModeratorTry:
function angelo_filter_activity( $retval ) { $retval['scope'] = 'bbp_reply_create,bbp_topic_create'; return $retval; } add_filter( 'bp_after_has_activities_parse_args', 'angelo_filter_activity' );August 10, 2015 at 4:47 pm #242974In reply to: documentation for remove_action activity streams
danbp
Participanti wouldn’t remove the whole action hook, as other functionnalities from other plugins, can use it. Filtering is even better.
bp_parse_{component}_argsis intended to filter template loops.If you remove an {activity} type with this function, it will remove that activity from each activity feed (swa, profile and group). Something like an all or nothing thing.
bp_parse return values. So if you want to remove something, you have to list what you want to keep to show, and not what to remove !
Here a snippet, listing all existing BP activity types (2.2.x). Simply comment or remove the type you don’t want.
function my_bp_activity_types( $retval ) { // list of all BP activity types - remove or comment those you won't show. $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; } add_filter( 'bp_after_has_activities_parse_args', 'my_bp_activity_types' );IMPORTANT: copy/paste to bp-custom.php or child-theme functions.php. Used as-is will do nothing ! You have to remove the type you don’t want from the list….
Third party plugins (like bbPress) use also activity types. Easiest way to get the right type name is to check xxxx_bp_activity table in DB and search for it in the Type column.
@umar007, removingfriendship_createdwill solve your question.
@djsteveb, removenew_avatar! 😉July 28, 2015 at 8:33 am #242486danbp
Participantas you discovered already, the CSS trick is a poor solution.
Two solution are on hand.
A first one, which applies to all activity feeds.
Basically the below snippet handles globally the activties output. You simply remove the activity(ies) you don’t want to see from the list. Note that almost all activity types are listed.
Add it to child functions.php or to bp-custom.phpfunction demo_parse( $retval ) { // existing BP/bbP activities // remove the one you wont to see from that list $retval['action'] = ' activity_comment, activity_update, bbp_topic_create, bbp_reply_create, friendship_created, joined_group, last_activity, new_avatar, new_blog_post, new_member, updated_profile '; return $retval; } add_filter( 'bp_after_has_activities_parse_args', 'demo_parse' );Codex:
The second solution, is to use a child-theme with a modified activity loop. This let you handle finer condition for each user.
Read this tut how you can do that.
Codex:
May 15, 2015 at 6:03 pm #239129r-a-y
KeymasterThe simple thing here is to remove all your custom code snippets that are interacting with the activity stream.
In your original post, I see you’re using this:
remove_filter( 'bp_after_has_activities_parse_args', 'ray_bp_display_comments_stream', 20 );Which means you have a function called
ray_bp_display_comments_stream()somewhere which is causing the singular activity comment entries to display.May 15, 2015 at 7:17 am #239104danbp
Participantthank you for your help, but please, don’t give a 4 years old solution without testing it.
At first, the snippet contains cote errors, and second, it doesn’t work with BP 2.x, as things has changed.You can easily modify your template loop by using bp_parse_args function.
Here a working example (activity-update is commented – uncomment to see the difference)
You simply have to list what to show. Anything not listed will be ignored, on all activity feeds.
Add this to bp-custom.php or child theme functions.php
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' );danbp
ParticipantHi,
to show only notices (aka updates) on the SWA, try this snippet (place in bp-custom.php)
function make_swa_show_notice_only( $retval ) { if ( bp_is_page( 'activity' ) ) { $retval['action'] = 'activity_update'; } return $retval; } add_filter( 'bp_after_has_activities_parse_args', 'make_swa_show_notice_only' );Reference: https://codex.buddypress.org/developer/using-bp_parse_args-to-filter-buddypress-template-loops/
March 14, 2015 at 7:55 pm #236020In reply to: Hiding stuff from the Activity stream
danbp
ParticipantRecently introduced function
bp_parse_argsallows since 2.0 to modify easely your templates. Faster and lighter than a plugin.As example, show only updates on the SWA (add snippet to bp-custom.php or child-theme functions.php)
function make_swa_show_notice_only( $retval ) { if ( bp_is_page( 'activity' ) ) { $retval['action'] = 'activity_update'; } return $retval; } add_filter( 'bp_after_has_activities_parse_args', 'make_swa_show_notice_only' ); -
AuthorSearch Results