[Appointments+] APPOINTMENTS+ Booking rules limit numbers per day


I have 10 room to manage and the rule would be: each person can book max 3hrs per day, but not limit to another date in "upper limit".

And I reference the post:


Try to modify the code, but when reach one day limit, I can't booking another date in "upper limit".

// Works only if login required
function limit_active_apps( $reply_array ) {
global $wpdb, $appointments;
$current_user = wp_get_current_user();
$current_user_id = $current_user->ID;
$app_table = $wpdb->prefix . 'app_appointments';
// Change statuses as required. i.e. remove pending condition if you wish
$count = $wpdb->get_var( "SELECT COUNT(*) FROM " . $app_table . " WHERE user=" . $current_user_id . " AND (status='pending' OR status='confirmed' OR status='paid' ) and created > DATE_SUB(CURDATE(), INTERVAL 1 DAY)" );

if ( $count >= 3)
return array( 'error'=>'You have reached maximum allowed number of appointments' );
return $reply_array;
add_filter( 'app_pre_confirmation_reply', 'limit_active_apps' );

Please help me for this needs.
Thank you guys!