Skip to content

Instantly share code, notes, and snippets.

@bappi-d-great
Created August 29, 2014 18:35
Show Gist options
  • Save bappi-d-great/5cadd0a31d364c35d11c to your computer and use it in GitHub Desktop.
Save bappi-d-great/5cadd0a31d364c35d11c to your computer and use it in GitHub Desktop.
WPMU A+ allow one appointment per day
<?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