---
title: Ignore capacity restrictions based on user role
description: "The following code snippets show how to ignore the capacity restrictions you set based on the current logged in user's role. ## Ignore maxed out order capacity for a user role The code below would ignore the instances where the…"
url: "https://chwazidatetime.com/docs/ignore-capacity-restrictions-based-on-user-role/"
updated: "2026-01-30"
category: Custom Code Samples
---

# Ignore capacity restrictions based on user role

The following code snippets show how to ignore the capacity restrictions you set based on the current logged in user's role.

## Ignore maxed out order capacity for a user role

The code below would ignore the instances where the order capacity has been reached. However, that user role would still reduce the overall available order capacity. To prevent a user role from reducing order capacity, please see next section.

**NOTE:** Use this snippet if you have capacity restrictions set as "Day".

```
function sl_cc_chwazi_ignore_day_capacity_reached( $ignore_capacity_reached, $args ) {

			// $args is an array containing the following keys allowing for more complex logic:
			// order_type
			// date
			// day_of_the_week
			// transient_name
			// current_pending_orders
			// max_orders_for_day
			// posted_values ($_POST values)

			$role_name = 'custom_role'; // Change this to the role you want to ignore the limit for.

			$user      = wp_get_current_user();
			if ( ! is_object( $user ) && empty( $user->roles ) ) {
				return $ignore_capacity_reached;
			}

			if ( in_array( $role_name, $user->roles ) ) {
				return true;
			}

			return $ignore_capacity_reached;
}
add_filter( 'chwazi_ignore_day_capacity_reached', 'sl_cc_chwazi_ignore_day_capacity_reached', 10, 2 );
```

**NOTE:**Use this snippet if you have capacity restrictions set as "Timeslot".

```
function sl_cc_chwazi_ignore_timeslot_capacity_reached( $ignore_capacity_reached, $args ) {

    // $args is an array containing the following keys allowing for more complex logic:
    // order_type
    // date
    // day_of_the_week
    // transient_name
    // current_pending_orders
    // max_orders_for_day_timeslot
    // posted_values ($_POST values)

    $role_name = 'custom_role'; // Change this to the role you want to ignore the limit for.

    $user = wp_get_current_user();
    if ( ! is_object( $user ) && empty( $user->roles ) ) {
        return $ignore_capacity_reached;
    }

    if ( in_array( $role_name, $user->roles ) ) {
        return true;
    }

    return $ignore_capacity_reached;
}
add_filter( 'chwazi_ignore_timeslot_capacity_reached', 'sl_cc_chwazi_ignore_timeslot_capacity_reached', 10, 2 );
```

## Prevent a user role from reducing the order capacity

Below snippet prevents a user role from reducing the overall order capacity. Whether you're using the capacity by "Day" or "Timeslot" option.

```
 function sl_cc_dont_apply_capacity_decrement_for_role($apply_capacity_decrement, $args) {

    // $args is an array containing the following keys allowing for more complex logic:
    // order_type
    // capacity_by
    // date
    // time
    // prev_value
    // current_value
    // transient_name

    $role_name = 'custom_role'; // Change this to the role you want to ignore the limit for.

    $user = wp_get_current_user();
    if ( ! is_object( $user ) && empty( $user->roles ) ) {
        return $apply_capacity_decrement;
    }

    if ( in_array( $role_name, $user->roles ) ) {
        return false;
    }

    return $apply_capacity_decrement;
}
add_filter('chwazi_apply_capacity_decrement', 'sl_cc_dont_apply_capacity_decrement_for_role', 10, 2);
```
