Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'pre_get_posts', function( $query ) {
- if(!$query->is_main_query()) return;
- if( is_shop() ) {
- $vacation_args = array(
- 'role__in' => apply_filters( 'wcfmmp_allwoed_vendor_user_roles', array( 'wcfm_vendor' ) ),
- 'meta_query' => array(
- array(
- 'key' => 'wcfmmp_profile_settings',
- 'value' => ';s:18:"wcfm_vacation_mode";s:3:"yes";',
- 'compare' => 'LIKE',
- )
- ),
- 'fields' => 'ID'
- );
- $on_vacation = get_users( $vacation_args );
- $vacation_posts = new WP_Query( array(
- 'post_type' => 'product',
- 'author__in' => $on_vacation,
- 'posts_per_page' => -1,
- 'fields' => 'ids'
- ) );
- $post_ids = array();
- if ( $vacation_posts->have_posts() ) {
- $post_ids = $vacation_posts->posts;
- }
- wp_reset_postdata();
- $query->set( 'post__not_in', $post_ids );
- }
- }, 100 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement