Skip to main content
added 14 characters in body
Source Link
bueltge
  • 17.1k
  • 7
  • 65
  • 97

The core havehas functions like current_user_can to check for an capability of a role or check the role directly. The follow example extend your source for this check so that the function not (!) run, if the current user haven't the rights, the capability of his role.

add_filter('request', function( $vars ) { // Check the capability of the current user. if ( ! current_user_can( 'manage_options' ) ) return; global $typenow, $wpdb; // Add logic to determine if the orders list should be filtered, and which // currency $currency = 'GBP'; if($typenow == 'shop_order') { $vars['meta_query']['relation'] = 'AND'; // Only show orders in the specific currency $vars['meta_query'] = array( array( 'key' => '_order_currency', 'value' => $currency, 'compare' => '=', ), ); } return $vars; }, 15 ); 

The core have functions like current_user_can to check for an capability of a role or check the role. The follow example extend your source for this check so that the function not run, if the current user haven't the rights, the capability of his role.

add_filter('request', function( $vars ) { // Check the capability of the current user. if ( ! current_user_can( 'manage_options' ) ) return; global $typenow, $wpdb; // Add logic to determine if the orders list should be filtered, and which // currency $currency = 'GBP'; if($typenow == 'shop_order') { $vars['meta_query']['relation'] = 'AND'; // Only show orders in the specific currency $vars['meta_query'] = array( array( 'key' => '_order_currency', 'value' => $currency, 'compare' => '=', ), ); } return $vars; }, 15 ); 

The core has functions like current_user_can to check for an capability of a role or check the role directly. The follow example extend your source for this check so that the function not (!) run, if the current user haven't the rights, the capability of his role.

add_filter('request', function( $vars ) { // Check the capability of the current user. if ( ! current_user_can( 'manage_options' ) ) return; global $typenow, $wpdb; // Add logic to determine if the orders list should be filtered, and which // currency $currency = 'GBP'; if($typenow == 'shop_order') { $vars['meta_query']['relation'] = 'AND'; // Only show orders in the specific currency $vars['meta_query'] = array( array( 'key' => '_order_currency', 'value' => $currency, 'compare' => '=', ), ); } return $vars; }, 15 ); 
Source Link
bueltge
  • 17.1k
  • 7
  • 65
  • 97

The core have functions like current_user_can to check for an capability of a role or check the role. The follow example extend your source for this check so that the function not run, if the current user haven't the rights, the capability of his role.

add_filter('request', function( $vars ) { // Check the capability of the current user. if ( ! current_user_can( 'manage_options' ) ) return; global $typenow, $wpdb; // Add logic to determine if the orders list should be filtered, and which // currency $currency = 'GBP'; if($typenow == 'shop_order') { $vars['meta_query']['relation'] = 'AND'; // Only show orders in the specific currency $vars['meta_query'] = array( array( 'key' => '_order_currency', 'value' => $currency, 'compare' => '=', ), ); } return $vars; }, 15 );