Users::get_alternative_users( $alternative_hosts = array(), string $selected_alt_hosts = '', string $current_host = '', null|string $account_id = null )
Get the alternative users that can be used as hosts.
Contents
Parameters
-
(<span class="TribeEventsVirtualMeetingsZoomarray">TribeEventsVirtualMeetingsZoomarray) (Required) An array of Zoom Users to use as the alternative hosts.
- $selected_alt_hosts
-
(string) (Optional) The list of alternative host emails.
Default value: ''
- $current_host
-
(string) (Optional) The email of the current host.
Default value: ''
- $account_id
-
(null|string) (Optional) The account id to use to get the users with.
Default value: null
Return
(array|bool|mixed) An array of Zoom Users to use as the alternative hosts.
Source
File: src/Tribe/Meetings/Zoom/Users.php
public function get_alternative_users( $alternative_hosts = [], $selected_alt_hosts = '', $current_host = '', $account_id = null ) {
$all_users = $this->get_formatted_hosts_list( $account_id );
$selected_alt_hosts = explode( ';', $selected_alt_hosts );
// Filter out the current host email and any user that is not a valid alternative host.
// Using array_values to reindex from zero or the options do not show in the multiselect.
$alternative_hosts = array_values(
array_filter(
$all_users,
static function ( $user ) use ( $current_host ) {
return isset( $user['alternative_host'] )
&& true === $user['alternative_host']
&& $user['text'] !== $current_host;
}
)
);
// Change the dropdown value to the email for alternative hosts because that is what Zoom returns.
$alternative_hosts_email_id = array_map(
static function ( $user ) use ( $selected_alt_hosts ) {
$user['id'] = $user['text'];
$user['selected'] = in_array( $user['text'], $selected_alt_hosts ) ? true : false;
return $user;
},
$alternative_hosts
);
return $alternative_hosts_email_id;
}
Changelog
| Version | Description |
|---|---|
| 1.4.0 | Introduced. |