Skip to:
Content
Pages
Categories
Search
Top
Bottom

Add CPT comments in activities feed doesn’t work


  • gilldart
    Participant

    @gilldart

    Hi,

    I have a Custom Post Type ‘golfs’ created with CPT UI.
    I try to get the golfs comments (activated) in the Activites feed of BuddyPress without success…

    I put the code i found here ( https://codex.buddypress.org/plugindev/post-types-activities/ ) in my bp-custom.php file :

    function customize_page_tracking_args() {
        // Check if the Activity component is active before using it.
        if ( ! bp_is_active( 'activity' ) ) {
            return;
        }
     
        // Don't forget to add the 'buddypress-activity' support!
        add_post_type_support( 'golfs', 'buddypress-activity' );
     
        /**
         * Also don't forget to allow comments from the WordPress Edit Page screen
         * see this screencap https://cldup.com/nsl4TxBV_j.png
         */
     
        bp_activity_set_post_type_tracking_args( 'golfs', array(
            'action_id'                         => 'new_blog_page',
            'bp_activity_admin_filter'          => __( 'Published a new page', 'custom-textdomain' ),
            'bp_activity_front_filter'          => __( 'Page', 'custom-textdomain' ),
            'bp_activity_new_post'              => __( '%1$s posted a new <a href="%2$s">page</a>', 'custom-textdomain' ),
            'bp_activity_new_post_ms'           => __( '%1$s posted a new <a href="%2$s">page</a>, on the site %3$s', 'custom-textdomain' ),
            'contexts'                          => array( 'activity', 'member' ),
            'comment_action_id'                 => 'new_blog_page_comment',
            'bp_activity_comments_admin_filter' => __( 'Commented a page', 'custom-textdomain' ),
            'bp_activity_comments_front_filter' => __( 'Pages Comments', 'custom-textdomain' ),
            'bp_activity_new_comment'           => __( '%1$s commented on the <a href="%2$s">page</a>', 'custom-textdomain' ),
            'bp_activity_new_comment_ms'        => __( '%1$s commented on the <a href="%2$s">page</a>, on the site %3$s', 'custom-textdomain' ),
            'position'                          => 100,
        ) );
    }
    add_action( 'bp_init', 'customize_page_tracking_args' );

    New golfs are displayed in the activities feed but not the new comment.

    Can anybody tell me what’s wrong ?

    WP 6.2.2
    BuddyPress 11.2.0
    PHP 7.4

    Thank’s in advance
    Gil

Viewing 1 replies (of 1 total)

  • VibeThemes
    Participant

    @vibethemes

    the code is for publish of new golfs only. So it wont work for comments.

    For comments you need to use wp_insert_comment hook

    and bp_activity_add function

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