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
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.