1 user.admin.inc user_admin_role_submit($form, &$form_state)

Form submit handler for the user_admin_role() form.

File

core/modules/user/user.admin.inc, line 764
Admin page callbacks for the User module.

Code

function user_admin_role_submit($form, &$form_state) {
  // Set the default redirect.
  $redirect = 'admin/config/people/roles';

  if (empty($form_state['role'])) {
    // Save a new role.
    $role = (object) array(
      'name' => $form_state['values']['name'],
      'label' => $form_state['values']['label'],
      'description' => $form_state['values']['description'],
    );
    user_role_save($role);
    backdrop_set_message(t('The %role role has been added.', array('%role' => $role->label)));
    // Determine whether it was the 'Save and set permissions' or the 'Save
    // role' button that was clicked, and set the form redirect accordingly.
    if ($form_state['triggering_element']['#id'] == 'edit-continue') {
      $redirect = 'admin/config/people/permissions';
    }
  }
  else {
    // Update existing role.
    $role = $form_state['role'];
    $role->label = $form_state['values']['label'];
    $role->description = $form_state['values']['description'];
    user_role_save($role);
    backdrop_set_message(t('The %role role has been saved.', array('%role' => $role->label)));
  }

  $form_state['redirect'] = $redirect;
}