Skip to content

Commit

Permalink
Tweak to permission checks on export
Browse files Browse the repository at this point in the history
  • Loading branch information
alicolville committed Aug 11, 2017
1 parent f5da146 commit e5c5232
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pro-features/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
function ws_ls_export_data() {

// Ensure the user has relevant permissions
ws_ls_user_data_permission_check();
ws_ls_export_permission_check();

// Do we have a user ID? If so limit data
$filters = (false === empty($_GET['user-id']) && is_numeric($_GET['user-id'])) ? ['user-id' => intval($_GET['user-id'])] : false;
Expand Down Expand Up @@ -260,3 +260,11 @@ function ws_ls_export_verify_type($content_type) {
in_array($content_type, ['text/csv', 'application/json'])
) ? $content_type : 'text/csv';
}
/**
* Helper function to disable admin page if the user doesn't have the correct user role.
*/
function ws_ls_export_permission_check() {
if ( !current_user_can( WE_LS_VIEW_EDIT_USER_PERMISSION_LEVEL ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' , WE_LS_SLUG) );
}
}

0 comments on commit e5c5232

Please sign in to comment.