a
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudanti.
a
Follow Me
Search
woogc/network_orders/get_orders/mysql_query/WHERE - WooCommerce MultiSite Global Cart
15503
documentation-template-default,single,single-documentation,postid-15503,theme-awake,cookies-not-set,eltd-core-1.1,woocommerce-no-js,awake child-child-ver-1.0.0,awake-ver-1.0,eltd-smooth-scroll,eltd-smooth-page-transitions,eltd-mimic-ajax,eltd-grid-1200,eltd-blog-installed,eltd-default-style,eltd-fade-push-text-top,eltd-header-standard,eltd-sticky-header-on-scroll-down-up,eltd-default-mobile-header,eltd-sticky-up-mobile-header,eltd-menu-item-first-level-bg-color,eltd-dropdown-slide-from-top,eltd-,eltd-fullscreen-search eltd-search-fade,eltd-side-menu-slide-from-right,wpb-js-composer js-comp-ver-6.0.3,vc_responsive
 

woogc/network_orders/get_orders/mysql_query/WHERE

WooCommerce MultiSite Global Cart / woogc/network_orders/get_orders/mysql_query/WHERE
Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on TumblrPin on PinterestEmail this to someonePrint this page

woogc/network_orders/get_orders/mysql_query/WHERE

Name: woogc/network_orders/get_orders/mysql_query/WHERE
Type: Filter
Arguments: $mysql_query, $blog_id

The filter can be used to modify the MySQL query used by the Network Orders interface to output the orders from all shops.

The following code example shows only the orders for shop_manager roles, from shops where the user have access :


    add_filter ( 'woogc/network_orders/get_orders/mysql_query/WHERE', '_custom_network_orders_mysql_query_WHERE_2', 10, 2 );
    function _custom_network_orders_mysql_query_WHERE_2 ( $mysql_query, $blog_id )
        {
            global $wpdb;
            
            switch_to_blog( $blog_id ); 
            
            $user = wp_get_current_user();
            if ( in_array( 'administrator', (array) $user->roles ) ) 
                return $mysql_query;
                
            if ( in_array( 'shop_manager', (array) $user->roles ) ) 
                return $mysql_query;
                
            $mysql_query    .=  "   AND 1 = 2";    
            
            restore_current_blog();
            
            return $mysql_query;   
            
        }

The code should be placed inside a php file on wp-content/mu-plugins folder.