Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter('wcfmmp_exclude_vendors_list', function($exclude_vendor_list) {
- global $wpdb;
- $vacation_args = array(
- 'role__in' => apply_filters( 'wcfmmp_allwoed_vendor_user_roles', array( 'wcfm_vendor' ) ),
- 'meta_query' => array(
- array(
- array(
- 'key' => 'wcfmmp_profile_settings',
- 'value' => ';s:18:"wcfm_vacation_mode";s:3:"yes";',
- 'compare' => 'LIKE',
- ),
- array(
- 'key' => 'wcfmmp_profile_settings',
- 'value' => ';s:30:"wcfm_disable_vacation_purchase";s:3:"yes";',
- 'compare' => 'LIKE',
- ),
- ),
- ),
- 'fields' => 'ID',
- );
- $on_vacation = get_users( $vacation_args );
- $sql = "select user_id, meta_value from {$wpdb->prefix}usermeta where user_id IN (" . implode( ",", $on_vacation ) . ") AND meta_key = 'wcfmmp_profile_settings'";
- $result = $wpdb->get_results($sql);
- $exclude_vendor = [];
- if( !empty( $result ) ) {
- foreach ($result as $value) {
- $settings = maybe_unserialize($value->meta_value);
- if(isset($settings['wcfm_vacation_mode_type']) && 'instant' == $settings['wcfm_vacation_mode_type']) {
- $exclude_vendor[] = $value->user_id;
- continue;
- }
- $wcfm_vacation_start_date = isset($settings['wcfm_vacation_start_date']) ? $settings['wcfm_vacation_start_date'] : '';
- $wcfm_vacation_end_date = isset($settings['wcfm_vacation_end_date']) ? $settings['wcfm_vacation_end_date'] : '';
- if( $wcfm_vacation_start_date && $wcfm_vacation_end_date ) {
- $current_time = strtotime( 'midnight', current_time( 'timestamp' ) );
- $start_time = strtotime( $wcfm_vacation_start_date );
- $end_time = strtotime( $wcfm_vacation_end_date );
- if( ($current_time >= $start_time) && ($current_time <= $end_time) ) {
- $exclude_vendor[] = $value->user_id;
- continue;
- }
- }
- }
- $exclude_vendor_list = array_unique(array_merge($exclude_vendor_list, $exclude_vendor));
- }
- return $exclude_vendor_list;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement