Replies
Brajesh, thanks a lot, it’s working 🙂 Now I only need to figure out how to incorporate the link to the profile and the @ 🙂 Thanks a lot for the tip! Appreciate it!
- Plamen Peev on August 21, 2019 at 11:39 am in reply to: [Resolved] Comments in activity stream #24814
Thanks, Brajesh. All the best.
- Plamen Peev on August 19, 2019 at 12:04 pm in reply to: [Resolved] Comments in activity stream #24740
‘function buddydev_disable_activity_blog_comment_recording_conditionally( $enabled, $blog_id, $post_id, $user_id, $comment_id ) {
// use $post_id to decide.
// set $enabled= false; to stop recording comment.
if ( ! in_category( ‘community’, $post_id ) ) {
$enabled = false;
}return $enabled;
}add_filter( ‘bp_activity_post_pre_comment’, ‘buddydev_disable_activity_blog_comment_recording_conditionally’, 20, 5 );’
That’s all I’m using. You put it together for me a while ago to be able to filter what’s coming in the feed.
Thanks,
Plamen
Thanks, Brajesh,
Found that I can control the output from here:
‘// Replace @mention text with userlinks.
foreach( (array) $usernames as $user_id => $username ) {
$activity->content = preg_replace( ‘/(@’ . $username . ‘\b)/’, “@$username“, $activity->content );’
}Changing $username to $display_name does not work however.
- This reply was modified 5 years, 3 months ago by Plamen Peev.
- Plamen Peev on April 18, 2019 at 11:21 am in reply to: [Resolved] Activity Sitewide stream filter posts by category #22394
Thank you, Brajesh,
Working just the way I wanted now.
Bow down to your level of expertise
and thank you again for your help and kind support.All the best,
Plamen
- Plamen Peev on April 17, 2019 at 3:10 pm in reply to: [Resolved] Activity Sitewide stream filter posts by category #22370
Thanks, Brajesh,
Appreciate your kind assistance.
The simple logic I’m trying to achieve is to
allow comments from “community” category blog posts only
and disallow comments from any other category.Can’t wait to test your suggestions tomorrow.
Will keep you posted.Once again – big thank you!
Plamen
- Plamen Peev on April 17, 2019 at 3:01 pm in reply to: [Resolved] Activity Sitewide stream filter posts by category #22367
Thank you so much, Brajesh. Looking up to your skills 🙂 That’s awesome!
Could I use it with $category_id instead of $post_id or it would not work?
Maybe I should create a custom post type instead.Thanks again – will test it out and report.
Best,
Plamen
- Plamen Peev on April 17, 2019 at 12:59 pm in reply to: [Resolved] Activity Sitewide stream filter posts by category #22362
Brajesh,
Any idea how I could tweak the code above to exclude activity updates on new post comments as well?
Thanks a lot,
Plamen
- Plamen Peev on April 16, 2019 at 11:50 am in reply to: [Resolved] Activity Sitewide stream filter posts by category #22324
Just a quick update:
The code below allows me to successfully filter out new posts updates from category ID=1 but it’s not working for new comments.
function buddydev_disable_category_post_from_activity_recording( $enabled, $blog_id, $post_id, $user_id, $comment_id ) { $category_id = 1; $taxonomy = 'category'; if ( has_term( $category_id, $taxonomy, $post_id, $comment_id ) ) { // I could use has_category() but has_terms can be a better example for future customization. $enabled = false; } return $enabled; } add_filter( 'bp_activity_post_pre_publish', 'buddydev_disable_category_post_from_activity_recording', 10, 4 );
- Plamen Peev on April 16, 2019 at 11:36 am in reply to: [Resolved] Activity Sitewide stream filter posts by category #22323
Thanks a lot, Brajesh,
Best,
Plamen