CPT in activity feed, except 1 category?
-
Hi,
So i have this script in my /plugins/bp-custom.php file (see below). I was wondering if it is possible to exclude new posts, from posting them on the activity wall, for a certain category. So that (i.e.) new posts that are posted in category_id 2 are not posted on the wall.Any ideas on this?
Here is my script:<?php //Listing activity support function customize_page_tracking_args_listing() { // 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( 'listing', '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( 'listing', array( 'action_id' => 'new_listing', 'bp_activity_admin_filter' => __( 'Post added', 'custom-textdomain' ), 'bp_activity_front_filter' => __( 'Post', 'custom-textdomain' ), 'bp_activity_new_post' => __( '%1$s added a new post called <a href="%2$s">[post]</a>', 'custom-textdomain' ), 'contexts' => array( 'activity', 'member' ), 'comment_action_id' => 'new_listing_comment', 'bp_activity_comments_admin_filter' => __( 'Commented on', 'custom-textdomain' ), 'bp_activity_comments_front_filter' => __( 'Comments on post', 'custom-textdomain' ), 'bp_activity_new_comment' => __( '%1$s commented on <a href="%2$s">a post</a>', 'custom-textdomain' ), 'position' => 100, ) ); } add_action( 'bp_init', 'customize_page_tracking_args_listing', 1000 ); function new_listing_include_post_type_title( $action, $activity ) { if ( empty( $activity->id ) ) { return $action; } if ( 'new_listing' != $activity->type ) { return $action; } preg_match_all( '/<a.*?>([^>]*)<\/a>/', $action, $matches ); if ( empty( $matches[1][1] ) || '[post]' != $matches[1][1] ) { return $action; } $post_type_title = bp_activity_get_meta( $activity->id, 'post_title' ); if ( empty( $post_type_title ) ) { switch_to_blog( $activity->item_id ); $post_type_title = get_post_field( 'post_title', $activity->secondary_item_id ); // We have a title save it in activity meta to avoid switching blogs too much if ( ! empty( $post_type_title ) ) { bp_activity_update_meta( $activity->id, 'post_title', $post_type_title ); } restore_current_blog(); } return str_replace( $matches[1][1], esc_html( $post_type_title ), $action ); } add_filter( 'bp_activity_custom_post_type_post_action', 'new_listing_include_post_type_title', 10, 2 );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.