BuddyDev

Search

Replies

  • Participant
    Level: Initiated
    Posts: 13
    Plamen Peev on #24865

    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!

  • Participant
    Level: Initiated
    Posts: 13
    Plamen Peev on #24814

    Thanks, Brajesh. All the best.

  • Participant
    Level: Initiated
    Posts: 13
    Plamen Peev on #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

  • Participant
    Level: Initiated
    Posts: 13
    Plamen Peev on #24739

    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.
  • Participant
    Level: Initiated
    Posts: 13
    Plamen Peev on #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

  • Participant
    Level: Initiated
    Posts: 13
    Plamen Peev on #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

  • Participant
    Level: Initiated
    Posts: 13
    Plamen Peev on #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

  • Participant
    Level: Initiated
    Posts: 13
    Plamen Peev on #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

  • Participant
    Level: Initiated
    Posts: 13
    Plamen Peev on #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 );
  • Participant
    Level: Initiated
    Posts: 13
    Plamen Peev on #22323

    Thanks a lot, Brajesh,

    Best,

    Plamen