You are here

function zoomapi_user_custcreate in Zoom API 7

Create Custom Zoom User.

Zoom custom accounts are accounts without a password. They are unable to log into the Zoom app or website. These are typically used to generate accounts used to host meetings. Users that use the meeting start url are automatically logged in as the host (custom) account.

Given that emails must still be unique, a fake email address is generated based on the account.

Parameters

object $account: The Drupal user account to generate the Zoom account for.

array $options: Optional array of Zoom user configuration options.

Return value

array An array of the Zoom user account information.

File

./zoomapi.module, line 283
Main file for the Zoom API module.

Code

function zoomapi_user_custcreate($account, array $options = []) {
  $zoomapi_user = new ZoomAPIUser();
  $email = !empty($options['email']) ? $options['email'] : zoomapi_user_custcreate_email_generate($account);
  $type = !empty($options['type']) ? $options['type'] : variable_get('zoomapi_user_type_default', ZOOMAPI_USER_TYPE_DEFAULT);

  // The 'track_id' on the zoom user will be used to track the Drupal user ID.
  $options['track_id'] = $account->uid;
  if (empty($account->data['zoomapi_user_id']) && ($zoom_user = $zoomapi_user
    ->custcreate($email, $type, $options))) {
    $account->data['zoomapi_user_id'] = $zoom_user['id'];
    $account->data['zoomapi_user_email'] = $zoom_user['email'];
    user_save($account);
    return $zoom_user;
  }
  return [];
}