BP_REST_XProfile_Repeater_Endpoint::update_item_permissions_check( WP_REST_Request $request )
Check if a given request has access to update a Repeater Group.
Description
Parameters
- $request
-
(Required) Full data about the request.
Return
(WP_Error|bool)
Source
File: bp-xprofile/classes/class-bp-rest-xprofile-repeater-endpoint.php
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 | public function update_item_permissions_check( $request ) { $retval = true; if ( ! is_user_logged_in() ) { $retval = new WP_Error( 'bp_rest_authorization_required' , __( 'Sorry, you are not allowed to update your profile repeater fields.' , 'buddyboss' ), array ( 'status' => rest_authorization_required_code(), ) ); } // Get the field group before it's deleted. $field_group = xprofile_get_field_group( (int) $request [ 'id' ] ); if ( true === $retval && empty ( $field_group ->id ) ) { $retval = new WP_Error( 'bp_rest_invalid_id' , __( 'Invalid Group ID.' , 'buddyboss' ), array ( 'status' => 404, ) ); } $repeater_enabled = bp_xprofile_get_meta( $field_group ->id, 'group' , 'is_repeater_enabled' , true ); if ( empty ( $field_group ) || 'on' !== $repeater_enabled ) { $retval = new WP_Error( 'bp_rest_invalid_repeater_id' , __( 'Invalid Repeater Group ID.' , 'buddyboss' ), array ( 'status' => 404, ) ); } /** * Filter the XProfile repeater fields `update_item` permissions check. * * @since 0.1.0 * * @param bool|WP_Error $retval Returned value. * @param WP_REST_Request $request The request sent to the API. */ return apply_filters( 'bp_rest_xprofile_repeater_fields_update_item_permissions_check' , $retval , $request ); } |
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.