bp_activity_post_type_unpublish( int $post_id, WP_Post|null $post = null )
Unpublish an activity for the custom post type.
Description
Parameters
- $post_id
-
(Required) ID of the post being unpublished.
- $post
-
(Optional) Post object.
Default value: null
Return
(bool) True on success, false on failure.
Source
File: bp-activity/bp-activity-functions.php
2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 | function bp_activity_post_type_unpublish( $post_id = 0, $post = null ) { if ( ! is_a ( $post , 'WP_Post' ) ) { return ; } // Get the post type tracking args. $activity_post_object = bp_activity_get_post_type_tracking_args( $post ->post_type ); if ( empty ( $activity_post_object ->action_id ) ) { return ; } if ( empty ( $post_id ) ) { $post_id = $post ->ID; } $delete_activity_args = array ( 'item_id' => get_current_blog_id(), 'secondary_item_id' => $post_id , 'component' => $activity_post_object ->component_id, 'type' => $activity_post_object ->action_id, 'user_id' => false, ); $deleted = bp_activity_delete_by_item_id( $delete_activity_args ); /** * Fires after the unpublishing for the custom post type. * * @since BuddyPress 2.2.0 * * @param array $delete_activity_args Array of arguments for activity deletion. * @param WP_Post $post Post object. * @param bool $activity Whether or not the activity was successfully deleted. */ do_action( 'bp_activity_post_type_unpublished' , $delete_activity_args , $post , $deleted ); return $deleted ; } |
Changelog
Version | Description |
---|---|
BuddyPress 2.2.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.