Tribe__Events__Community__Tickets__Main::user_has_edit_event_tickets_cap( array $all_caps, array $caps, array $args )
Determines whether the currently logged in user has the correct cap.
Contents
Parameters
- $all_caps
-
(array) (Required) User capabilities.
- $caps
-
(array) (Required) Caps being checked.
- $args
-
(array) (Required) Additional user_cap args.
Source
File: src/Tribe/Main.php
public function user_has_edit_event_tickets_cap( $all_caps, $caps, $args ) {
static $options;
// Bail if there isn't a cap or user_id
if ( empty( $caps[0] ) || empty( $args[1] ) ) {
return $all_caps;
}
$cap = $caps[0];
$user_id = $args[1];
// Bail if this isn't the cap we care about
if ( 'edit_event_tickets' !== $cap ) {
return $all_caps;
}
if ( ! $options ) {
$options = get_option( self::OPTIONNAME );
}
if ( ! isset( $all_caps[ $cap ] ) ) {
// assume the user has it - by default all users with accounts have it
$all_caps[ $cap ] = (bool) $options['edit_event_tickets_cap'];
}
// If split payments is enabled, let users create tickets
if ( ! $this->is_enabled() ) {
$all_caps[ $cap ] = false;
return $all_caps;
}
return $all_caps;
}