Created
August 29, 2014 18:35
-
-
Save bappi-d-great/5cadd0a31d364c35d11c to your computer and use it in GitHub Desktop.
WPMU A+ allow one appointment per day
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Works only if login required | |
function limit_active_apps( $reply_array ) { | |
global $wpdb, $current_user, $appointments; | |
// Change statuses as required. i.e. remove pending condition if you wish | |
$count = $wpdb->get_var( "SELECT COUNT(*) FROM " . $appointments->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' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment