Restrict number of bookings per month by Pro Site level


I was follow a comment that @aristath wrote regarding the support question Restrict number of bookings per month per user group.

I was wondering if their are Pro Site plugin functions to check the current Pro Site level? I want to limit the number of Appointment+ appointments,PER BLOG, by Pro Site level.

Something like current_blog_level() exists? then I can write something like

// 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 start > NOW() - INTERVAL 30 DAY " );

if(current_blog_level() == 1 && $count>8){return array( 'error'=>'You have reached 8 bookings max' ); return $reply_array;}
if(current_blog_level() == 2 && $count>12){return array( 'error'=>'You have reached 12 bookings max' ); return $reply_array;}
if(current_blog_level() == 3 && $count>15){return array( 'error'=>'You have reached 15 bookings max' ); return $reply_array;}

thank you,


  • Tyler Postle

    Hey there Tin,

    Hope you're doing well today and thanks for your question!

    Perhaps something like this would help, which was actually also written by the amazing Aristath :slight_smile:

    global $wpdb;
    $blog_id = $wpdb->blogid;
    $sql = "SELECT level FROM {$wpdb->base_prefix}pro_sites WHERE blog_ID = '$blog_id'";
    $level = $wpdb->get_var($sql);
    <?php if ($level == 1){ ?>
    	Level 1 content here
    <?php } ?>
    <?php if ($level == 2) { ?>
    	Level 2 content here
    <?php } ?>
    <?php if ($level == 3) { ?>
    	Level 3 content here
    <?php } ?>

    This allows you to add restrictions per pro site level. This way you can add the appropriate level per blog as needed :slight_smile:

    Would that work? Admittedly I'm not one of the best coders around here - so if you're still in need of a solution we can get one of your SLS(coding experts) to provide some guidance here as well.

    Look forward to hearing back!

    All the best,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.