function opigno_moxtra_app_user_insert in Opigno Moxtra App 7
Implements hook_user_insert()
File
- ./
opigno_moxtra_app.module, line 69
Code
function opigno_moxtra_app_user_insert(&$edit, $account, $category) {
$organization = variable_get('opigno_moxtra_app_org_id', NULL);
if (!empty($organization) && opigno_moxtra_app_organization_is_active()) {
if ($account->status == 1) {
$response = opigno_moxtra_app_api_opigno_create_users(array(
array(
'uid' => $account->uid,
'name' => $account->name,
'timezone' => $account->timezone,
),
));
if (isset($response->opigno_error_message)) {
drupal_set_message($response->opigno_error_message, 'error');
drupal_set_message(t('The user will be blocked. Try again by unblocking this user.'), 'warning');
db_update('users')
->condition('uid', $account->uid, '=')
->fields(array(
'status' => 0,
))
->execute();
}
}
}
}