| @@ -9,8 +9,9 @@ | ||
| 9 | 9 | use Jet_Form_Builder\Form_Manager; |
| 10 | 10 | use Jet_Form_Builder\Request\Exceptions\Plain_Value_Exception; |
| 11 | 11 | use JFB_Components\Rest_Api\Rest_Api_Endpoint_Base; |
| 12 | 12 | use JFB_Modules\Block_Parsers\Field_Data_Parser; |
| 13 | +use Jet_Form_Builder\Admin\Tabs_Handlers\Tab_Handler_Manager; | |
| 13 | 14 | |
| 14 | 15 | // If this file is called directly, abort. |
| 15 | 16 | if ( ! defined( 'WPINC' ) ) { |
| 16 | 17 | die; |
| @@ -35,16 +36,19 @@ | ||
| 35 | 36 | ); |
| 36 | 37 | } |
| 37 | 38 | |
| 38 | 39 | public function check_permission(): bool { |
| 39 | - return current_user_can( 'edit_jet_fb_forms' ); | |
| 40 | + $capability = Tab_Handler_Manager::get_form_records_access_capability(); | |
| 41 | + return current_user_can( 'edit_jet_fb_forms' ) || current_user_can( $capability ); | |
| 40 | 42 | } |
| 41 | 43 | |
| 42 | 44 | public function run_callback( \WP_REST_Request $request ) { |
| 43 | 45 | $form_id = $request->get_param( 'id' ); |
| 44 | 46 | $form = get_post( $form_id ); |
| 47 | + $capability = Tab_Handler_Manager::get_form_records_access_capability(); | |
| 45 | 48 | |
| 46 | - if ( absint( $form->post_author ) !== get_current_user_id() | |
| 49 | + if ( ! current_user_can( $capability ) | |
| 50 | + && absint( $form->post_author ) !== get_current_user_id() | |
| 47 | 51 | && ! current_user_can( 'edit_post', $form->ID ) |
| 48 | 52 | ) { |
| 49 | 53 | return new \WP_REST_Response( |
| 50 | 54 | array( |