No Lead Time Restriction for Admins

Removes lead time restriction for users with ‘manage_options’ capability (typically admins) by setting the availability start to now.

Instructions

See “Where do I put snippets?” in our documentation for installation instructions.

Code

Filename: gpb-no-lead-time-restriction-admins.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
/**
 * Gravity Perks // GP Bookings // No Lead Time Restriction for Admins
 * https://gravitywiz.com/documentation/gp-bookings/
 *
 * Removes lead time restriction for users with 'manage_options' capability (typically admins) by setting the availability start to now.
 */
add_filter( 'gpb_availability_start', function( $start, $service, $resource_ids ) {
	if ( ! current_user_can( 'manage_options' ) ) {
		return $start;
	}

	// Admins: no lead time restriction.
	return \Carbon\CarbonImmutable::now();
}, 20, 3 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.