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:
- Woocommerce – Specific template for product category? [closed]
- WooCommerce – How to Add a Custom Field to Cart Items and Cart Totals [closed]
- Is there a way to use latex \cite{reference} in wordpress?
- Show Similar Post Titles ( Similar to Stack Exchange )
- How to check plugin compatibility before upgrading WordPress
- How do I unlock a post programmatically?
- $wpdb->get_results leaking memory
- How to add a help tab to all admin pages – including plugin pages
- What is the purpose of adding a .po file?
- Plugin development: how to create a form and get custom data?
- Security error WP 4.0 + WP phpBB Bridge [closed]
- How to turn off email you receive when registered?
- Execute a function using ajax
- How to check if WordPress is updating plugins?
- Are there plugins that interfere with the admin part of Rss widget?
- How to make sexy bookmarks plugin work in WPMU
- Can’t get custom posts of taxonomy to show
- Where to put my global functions?
- Can’t create term for product attribute
- Adding Attachment Display Settings in custom media frame
- get shortcode value
- Unable to create new database table upon plugin activation using dbDelta
- Is it possible to install two mail plugins together in a single WordPress site? How to do it? [closed]
- how to implement a site like this in wordpress? [closed]
- wordpress to import joomla articles
- How can you include a theme template file from within a plugin (i.e. WooCommerce’s Shop page)?
- I have no idea “How change font for elements in widget?”
- Correct way to make meta box with more than one meta field secure
- I want to extend the current themes’ single.php to display the meta fields of my CPT
- Excluding a category from wp_query breaks recent post widget
- How can I restrict image upload dimensions for non-admin WordPress users?
- Basic Object Oriented plugin question
- How to remove traces from widget during uninstallation
- Change Product Addon price based on select Variation
- WooCommerce – Maximum qty per line per product
- admin-ajax.php warning max input vars exceeded on layered pop plugins [closed]
- Where can I always find the price of a plugin
- Zoninator zone manager plugin – get and set zones programmatically
- Image Manager Plugin [closed]
- WordPress.com Stats plugin is requiring login, and redirecting to WordPress.com on login
- Can someone explain me why apply_filters() is called here?
- “No Add Button” for me to customize my WordPress with themes and pluggins
- Disable Individual Plugins (specifically in Custom Post Types) on a per-post basis?
- WordPress crashes with “The service is unavailable.” after trying to upgrade plugins
- help with my wordpress website
- Removing Automatic Redirects Without Plugin
- Deactivate JS Script in Plugin Shortcode
- Basic question about accessing scripts in my plugin
- Adding Plugin Assets to Header
- How to Define Multiple List Tables in a Single Submenu
- How to create author profile showcase in wordpress
- WordPress SVN UTF-8 issue
- Plugin scheduled event not working
- Advanced Custom Fields (acf) – Filter Relationship by Taxonomies not Post Type
- change or add css to theme from plugin
- Update-safe translating of single text string in plugin
- At a Loss on over Page Peel Plugin Customization [closed]
- Custom Fields for Page Edits
- jQuery(‘#news-ticker’).cycle is not a function
- Looking for a photo management solution
- How to display an alert when deleting a plugin?
- How to make sure settings are not lost when plugin is updated?
- Effeciently adding Checkboxes to TablePress table cells
- WordPress Phone Field Check (use numbers, spaces and pluses)
- Import a folder containing HTML files and images to WordPress
- Can i stream data to a custom_post_type?
- Is there a hook similar to “save_post” which only fires AFTER the post is completely published?
- How to Fix WordPress multisite woocommerce 403 file error
- Define global variable in theme file and call that variable in plugin file
- Revolution Slider Toggle Devices not working
- automatically set random featured image by category in wordpress on post
- Using Shortcode Result In Custom HTML Block (Using Google Sheet JQuery Result As NumScroller data-max)
- How to publish post to individual based on date
- How To Export User’s Custom Fields in CSV or XLSX
- Some resources of my website are pointing to www.mysite.com/dev/ and trying to get rid of that append has been a headache
- Display plugin-generated content to override a placeholder page
- Is it possible to disable a theme programmatically?
- Members-only page, but accessible via sharable link
- Google trying to index child theme files
- The dropdown list in autocomplete is not showing
- How to overlay a webcomic plugin on top of a header image?
- Consume legacy rest api dependent upon WP API plugin
- Does WordPress have a way of changing the ‘Natural’ size of uploaded images?
- Infinite 301 redirects after definitions in “Redirections” plugin?
- How do I change tab url
- Disqus comments count taking long to update
- Escaping and sanitization
- Things that saved lose when logout
- How to save default values into an option and delete those upon actvation and deactivation in wordpress?
- How to Add Jquery FullCalendar in wp plugin in admin
- How to speed up installing plugins and upgrading WordPress
- Ajax, jQuery and WordPress
- PHP and Jquery pass value from form. Update function on DataBase
- Advanced Custom Field User Help URL
- No plugin updates after moving wp-config.php above root map
- Snippet displaying LearnDash parent course title with lesson title [closed]
- Want to show pop up image on home page every time when i refresh it [closed]
- woocommerce show cities state as dropdown list
- WordPress portfolio pagination on home page
- Wrapping code in an if block