Solved it, using pre_get_posts filter and WP_Query->set() method
function foo_filter_orders($query) {
global $pagenow;
$qv = &$query->query_vars;
$currentUserRoles = wp_get_current_user()->roles;
if (in_array('shop_manager', $currentUserRoles)) {
if ( $pagenow == 'edit.php' &&
isset($qv['post_type']) && $qv['post_type'] == 'shop_order' ) {
$query->set('meta_key', 'handle_by');
$query->set('meta_value', 'shopmanager1');
}
}
return $query;
}
add_filter('pre_get_posts', 'foo_filter_orders');
Related Posts:
- Redesigning Custom Post Type “Add New” page
- WooCommerce store with ~30,000 products [closed]
- Is there any record of installed plugins in the database?
- Why doesn’t the WordPress Importer update posts?
- Way to force media uploader use custom image size
- How to Add jQuery Infinite Scroll to My Custom Archive Page
- Change page title from plugin
- Override dynamic_sidebar() in plugin?
- A plugin for having rel=”nofollow” in posts?
- Why is this custom taxonomy showing in the database?
- Where is the source code that makes the “all” array grabs filters in the $wp_filter?
- How does WordPress ensure plugins run at the same time and how does it solve a plugin’s dependency on another one?
- Upload images from custom plugin using the media modal
- Options page not displayed under Settings menu
- How can I change plugin to give access to editor user role?
- How to include and use custom class files in plugin?
- How can I stop a plugin being updated?
- Change settings of get_post_type_object
- How does WordPress process plugin installations?
- Embed a Google Sheet as you view it in a separate tab?
- Changing labels of status filters for post grid
- Where to call add_shortcode function in WordPress Plugin Boilerplate?
- Fusion Slider Just keeps loading [closed]
- Social sharing toolkit is not showing on ajax load
- wordpress plugin is not activating from widget
- How can I check if on specific plugin generated page or child
- Error with third-party package: “Updating failed. Error message: The response is not a valid JSON response.” [closed]
- Transition from the pro version to the free version of the plugin
- There is any way to remove post-format filter? [closed]
- Show existing POST categories as items in the sidebar menu [closed]
- How to show only next post pagination link using wp_link_pages()
- Trying to fix form resubmition with PRG (Getting error: Cannot modify header information – headers already sent by)
- Retrieving Meta from Image Attachment
- Banner not visible after plugin publishing
- Plugin usage wordpress
- WordPress 4.3 broke meta redirect (with url params plugin)
- How to prevent PHP fatal error if plugin hasn’t been enabled and a method is called in theme file?
- Optimizing site
- Integrate Algolia to WordPress site
- Is there any pre-existing plugin to track and block IPs with suspicious activity on my site?
- How to make custom plugin run on demand?
- WooCommerce – set session with new cart item meta when updating cart item quantity [closed]
- Using WordPress to build membership Page
- All custom widgets are not showing in widget area at the same time
- How (or where) do I get wordpress plugin update download link?
- Apparent errer when installing plugin
- Issue removing Media Editor Tabs — Duplicate Items
- display link to a custom plugin in admin menu bar
- Quick press publish post hook
- A plugin popularity data inside “install new plugin” [closed]
- Error jQuery(domChunk).live is not a function
- I cannot include a file in my plugin settings page
- AJAX call inside plugin class is not getting to it’s response function
- force logged in user to stay in the dashboard
- Clicking custom plugin admin menu redirects to “No Update Required” on live site
- Creating an array from form inputs before it is posted to the options database
- activeren / deactiveren en verwijderen van een plugin (activate / deactivate and remove a plugin)
- How to assign a specific service to a specific provider based on location
- The plugin generated 227 characters of unexpected output during activation. If you notice “headers already sent” messages
- How to add the google ad conversion tracking code into the thank you page
- Custom Taxonomy is Missing (Or Limiting) Items
- $_POST field value gets altered after “init”
- 500 Internal server error wp_handle_upload_prefilter
- How can I disable W3 Total Cache Image Lazy Load for Specific Post Type?
- How can I pull in the most recent blog posts to a section with Elementor Page Builder?
- Point Python path in WordPress
- User updating their profile wipes my custom fields
- Migrations for plugins, page and theme: looking for a good approach
- How can I add a permissions callback to the REST API index pages?
- ERROR message: “The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.”
- Installation failed, trying to install ANY plugin
- Memberpress: Can I add a second email address?
- WordPress the_content Filter and GET Parameter
- Cannot modify header information – headers already sent during plugin activation
- How can I make the search bar in my wordpress site search all of the pages rather than just the blog posts?
- After form submission want to show success message in the form page
- Help Code Review – I need to write on .htaccess file from theme’s function.php
- Render Shortcode in Lightbox Gallery
- How to insert image into the Settings Page of a Plugin?
- How to force regenerate thumbnails in WordPress posts?
- change product image url in widgets & shop page
- dummy category, include .php file
- Hide some portion on single.php base on author
- Multiple Plugins Interacting with Menu
- Plugin constructor called multiple times
- How to add a handler for a button in plugin?
- Custom Form only for admin
- wpdb get_var is not returning any result (verified mysql query returns only one value)
- how to call jQuery in admin as well as in homepage
- How to programmatically detect how many posts are displayed per page?
- wordpress last all added get meta value by post id
- Is a custom post type considred a plugin?
- Migrate DB Plugin: Error “The directory needs to be writable”
- Woocommerce disable checkout on specific day
- How to delete Password Protected posts cookies when a user logged out from the site
- How to debug periodic performance issue
- wp_options Table keeps growing
- Run a function only once when logging into dashboard
- Stop the user if login from the cookies
- Randomly display activity posts on home page with buddypress