BP_REST_Attachments_Member_Cover_Endpoint::delete_item( WP_REST_Request $request )
Delete an existing user cover.
Description
Parameters
- $request
-
(Required) Full details about the request.
Return
(WP_REST_Response) | WP_Error
Source
File: bp-members/classes/class-bp-rest-attachments-member-cover-endpoint.php
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | public function delete_item( $request ) { $request ->set_param( 'context' , 'edit' ); $cover_url = bp_attachments_get_attachment( 'url' , array ( 'item_id' => $this ->user->ID, ) ); $deleted = bp_attachments_delete_file( array ( 'item_id' => (int) $this ->user->ID, ) ); if ( ! $deleted ) { return new WP_Error( 'bp_rest_attachments_member_cover_delete_failed' , __( 'Sorry, there was a problem deleting this user cover.' , 'buddyboss' ), array ( 'status' => 500, ) ); } // Build the response. $response = new WP_REST_Response(); $response ->set_data( array ( 'deleted' => true, 'previous' => $cover_url , ) ); /** * Fires after a user cover is deleted via the REST API. * * @param WP_User $user The user object. * @param WP_REST_Response $response The response data. * @param WP_REST_Request $request The request sent to the API. * * @since 0.1.0 */ do_action( 'bp_rest_attachments_member_cover_delete_item' , $this ->user, $response , $request ); return $response ; } |
Changelog
Version | Description |
---|---|
0.1.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.