Can I limit number of hours per week per client?

Hi,

Is it possible to limit number of appointments set by clients?

For example, I do not want clients to create more than 3 appointments per week. Is that possible?

Thanks.

  • aecnu
    • WP Unicorn

    Greetings azamt,

    Welcome to WPMU Dev!

    Thank you for the great questions and to the best of my knowledge there is not a facility to limit the amount of appointments a particular client can make.

    But before I stick foot in mouth, lets ask the Chief of the Appointments+ plugin project and ask him what advice/advise he may have for us regarding this feature.

    Though this may take a bit longer then a normal ticket, I will try to get him in here asap.

    Cheers, Joe

  • Hakan
    • The Incredible Smush

    Hi,

    Yes, that is possible, but if you require logging in to the website only.

    Add the following codes to functions.php of your current theme:

    function check_app_quota( $reply_array ) {
    if ( !is_user_logged_in() )
    return $reply_array;
    global $current_user, $wpdb;
    $count = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "app_appointments WHERE status<>'removed' AND user=".$current_user->ID." AND WEEK(created)=WEEK(CURDATE()) " );
    if ( $count>=3 ) {
    die(json_encode(array('error'=>'Sorry, your appointment quota is full')));
    }
    return $reply_array;
    }
    add_filter( 'app_pre_confirmation_reply', 'check_app_quota' );

    Note:

    1) You can remove status<>’removed’ condition if you wish.

    2) if you do not require login, there is no solution as user can always use another browser and/or PC and fake his identity.

    Cheers,

    Hakan

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.