Tribe__Tickets__Attendees::user_can( string $generic_cap, int $event_id )
Tests if the user has the specified capability in relation to whatever post type the ticket relates to.
Contents
For example, if tickets are created for the banana post type, the generic capability "edit_posts" will be mapped to "edit_bananas" or whatever is appropriate.
Parameters
- $generic_cap
-
(string) (Required)
- $event_id
-
(int) (Required)
Return
(boolean)
Source
File: src/Tribe/Attendees.php
public function user_can( $generic_cap, $event_id ) {
$type = get_post_type( $event_id );
// It's possible we'll get null back
if ( null === $type ) {
return false;
}
$type_config = get_post_type_object( $type );
if ( ! empty( $type_config->cap->{$generic_cap} ) ) {
return current_user_can( $type_config->cap->{$generic_cap} );
}
return false;
}
Changelog
| Version | Description |
|---|---|
| 4.6.2 | Introduced. |