Skip to:
Content
Pages
Categories
Search
Top
Bottom

How To Display Post Type Comments Within Groups


  • King Ding
    Participant

    @dazzerr

    Hello!

    Could someone perhaps help me adapt this code? Currently it shows a copy of all blog comments in the activity feed. I want it to rather show copies of learndash lesson comments to their associated course group. There is a plugin that does this, but it’s glorified with many other features, and the feature that I would like for doesn’t work as it should anyways.

    /* Post Comments in Buddypress Activity */
    function bca_record_activity($comment_id, $approval) {
        if($approval == 1) {
            $comment = get_comment($comment_id);
            $userlink = bp_core_get_userlink($comment->user_id);
            $postlink = '<a href="' . get_permalink($comment->comment_post_ID) . '">' 
                            . get_the_title($comment->comment_post_ID) . '</a>';
     
            bp_activity_add(array(
                'action'            => sprintf( __( '%1$s commented on the lesson: %2$s', 'buddypress' ), 
                                                    $userlink, $postlink),
                'content'           => $comment->comment_content,
                'component'         => 'bp_plugin',
                'user_id'           => $comment->user_id,
                'type'              => 'new_blog_comment',
            ));
         
        }
    }
    //comment_post is triggered "just after a comment is saved in the database".
    add_action('comment_post', 'bca_record_activity', 10, 2);
    // We want activity entries of blog comments to be shown as "mini"-entries
    function bca_minify_activity($array) {
        $array[] = 'new_blog_comment';
        return $array;
    }
    add_filter('bp_activity_mini_activity_types', 'bca_minify_activity');
    // Disables comments on this type of activity entry
    function bca_remove_commenting($can_comment) {
        if($can_comment == true) {
    		$can_comment = ! ('new_blog_comment' == bp_get_activity_action_name());
        }
        return $can_comment;
    }
    add_filter('bp_activity_can_comment', 'bca_remove_commenting');

    Plugin I reference: https://wordpress.org/plugins/buddypress-learndash/

    Your time and support is greatly appreciated!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar