Tribe__Events__Community__Tickets__Main::user_has_sell_event_tickets_cap( array $all_caps, array $caps, array $args )

Determines whether or not the currently logged in user has the correct cap to sell tickets (has PayPal info entered if split payments is enabled)


Parameters #

$all_caps

(array) (Required) User capabilities

$caps

(array) (Required) Caps being checked

$args

(array) (Required) Additional user_cap args


Top ↑

Return #

(array)


Top ↑

Source #

File: src/Tribe/Main.php

	public function user_has_sell_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 ( 'sell_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 ] = user_can( $user_id, 'edit_event_tickets' );
		}

		// If split payments is enabled, let users create tickets
		if ( $this->is_split_payments_enabled() ) {
			// If enabled, make sure the user has their paypal email set
			$meta = get_user_meta( $user_id, Tribe__Events__Community__Tickets__Payment_Options_Form::$meta_key, true );
			if ( empty( $meta['paypal_account_email'] ) ) {
				$all_caps[ $cap ] = false;
				return $all_caps;
			}
		}

		return $all_caps;
	}