bp_activity_delete( array|string $args = '' )
Delete activity item(s).
Description
If you’re looking to hook into one action that provides the ID(s) of the activity/activities deleted, then use:
add_action( ‘bp_activity_deleted_activities’, ‘my_function’ );
The action passes one parameter that is a single activity ID or an array of activity IDs depending on the number deleted.
If you are deleting an activity comment please use bp_activity_delete_comment();
See also
- BP_Activity_Activity::get(): For more information on accepted arguments.
Parameters
- $args
-
(Optional) To delete specific activity items, use $args = array( 'id' => $ids ); Otherwise, to use filters for item deletion, the argument format is the same as BP_Activity_Activity::get(). See that method for a description.
Default value: ''
Return
(bool) True on success, false on failure.
Source
File: bp-activity/bp-activity-functions.php
3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 | function bp_activity_delete( $args = '' ) { // Pass one or more the of following variables to delete by those variables. $args = bp_parse_args( $args , array ( 'id' => false, 'action' => false, 'content' => false, 'component' => false, 'type' => false, 'primary_link' => false, 'user_id' => false, 'item_id' => false, 'secondary_item_id' => false, 'date_recorded' => false, 'hide_sitewide' => false ) ); /** * Fires before an activity item proceeds to be deleted. * * @since BuddyPress 1.5.0 * * @param array $args Array of arguments to be used with the activity deletion. */ do_action( 'bp_before_activity_delete' , $args ); // Adjust the new mention count of any mentioned member. bp_activity_adjust_mention_count( $args [ 'id' ], 'delete' ); $activity_ids_deleted = BP_Activity_Activity:: delete ( $args ); if ( empty ( $activity_ids_deleted ) ) { return false; } // Check if the user's latest update has been deleted. $user_id = empty ( $args [ 'user_id' ] ) ? bp_loggedin_user_id() : $args [ 'user_id' ]; $latest_update = bp_get_user_meta( $user_id , 'bp_latest_update' , true ); if ( ! empty ( $latest_update [ 'id' ] ) ) { if ( in_array( (int) $latest_update [ 'id' ], ( array ) $activity_ids_deleted ) ) { bp_delete_user_meta( $user_id , 'bp_latest_update' ); } } /** * Fires after the activity item has been deleted. * * @since BuddyPress 1.0.0 * * @param array $args Array of arguments used with the activity deletion. */ do_action( 'bp_activity_delete' , $args ); /** * Fires after the activity item has been deleted. * * @since BuddyPress 1.2.0 * * @param array $activity_ids_deleted Array of affected activity item IDs. */ do_action( 'bp_activity_deleted_activities' , $activity_ids_deleted ); wp_cache_delete( 'bp_activity_sitewide_front' , 'bp' ); return true; } |
Changelog
Version | Description |
---|---|
BuddyPress 1.0.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.