Skip to content

Commit ecf892b

Browse files
committed
adds nonce and role verification to entry exports.
1 parent 74812cc commit ecf892b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

includes/admin/class-admin.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,19 @@ public function export_forms() {
170170
* @return void
171171
*/
172172
public function export_form_entries() {
173+
if ( ! current_user_can( 'administrator' ) ) {
174+
$error = new WP_Error( 'rest_weforms_invalid_permission', __( 'You do not have permission to export entries', 'weforms' ), [ 'status' => 404 ] );
175+
wp_die( esc_html__( $error->get_error_message(), 'weforms' ) );
176+
}
177+
178+
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'weforms-export-entries' ) ) {
179+
$error = new WP_Error( 'rest_weforms_invalid_nonce', __( 'Invalid nonce', 'weforms' ), [ 'status' => 404 ] );
180+
wp_die( esc_html__( $error->get_error_message(), 'weforms' ) );
181+
}
182+
173183
$form_id = isset( $_REQUEST['selected_forms'] ) ? absint( $_REQUEST['selected_forms'] ) : 0;
174184

175-
if ( !$form_id ) {
185+
if ( ! $form_id ) {
176186
return;
177187
}
178188

0 commit comments

Comments
 (0)