Attendees::user_can_manage_attendees( int $user_id, string $event_id = '' )
Determines if the current user (or an ID-specified one) is allowed to delete, check-in, and undo check-in attendees.
Contents
Parameters
- $user_id
-
(int) (Optional) The ID of the user whose access we're checking.
- $event_id
-
(string) (Optional) The ID of the event the user is managing.
Default value: ''
Return
(boolean)
Source
File: src/Tickets/Commerce/Reports/Attendees.php
public function user_can_manage_attendees( $user_id = 0, $event_id = '' ) {
$user_id = 0 === $user_id ? get_current_user_id() : $user_id;
$user_can = true;
// bail quickly here as we don't have a user to check.
if ( empty( $user_id ) ) {
return false;
}
/**
* Allows customizing the caps a user must have to be allowed to manage attendees.
*
* @since 5.2.0
*
* @param int $user_id The ID of the user whose capabilities are being checked.
*
* @param array $default_caps The caps a user must have to be allowed to manage attendees.
*/
$required_caps = apply_filters(
'tribe_tickets_caps_can_manage_attendees',
[
'edit_others_posts',
],
$user_id
);
// Next make sure the user has proper caps in their role.
foreach ( $required_caps as $cap ) {
if ( ! user_can( $user_id, $cap ) ) {
$user_can = false;
// break on first fail.
break;
}
}
/**
* Filter our return value to let other plugins hook in and alter things
*
* @since 5.2.0
*
* @param bool $user_can return value, user can or can't
* @param int $user_id id of the user we're checking
* @param int $event_id id of the event we're checking (matter for checks on event authorship)
*/
$user_can = apply_filters( 'tribe_tickets_user_can_manage_attendees', $user_can, $user_id, $event_id );
return $user_can;
}
Changelog
| Version | Description |
|---|---|
| 5.2.0 | Introduced. |