You are here

function regcode_roles_admin_submit in Registration codes 6

Same name and namespace in other branches
  1. 6.2 regcode_roles/regcode_roles.module \regcode_roles_admin_submit()
  2. 7.2 regcode_roles/regcode_roles.module \regcode_roles_admin_submit()
  3. 7 regcode_roles/regcode_roles.module \regcode_roles_admin_submit()

Create the roles

File

regcode_roles/regcode_roles.module, line 183

Code

function regcode_roles_admin_submit($form, $form_state) {
  $role = $form_state['values']['role'];
  $category = $form_state['values']['category'];
  $expiry_date = NULL;
  $expiry_duration = NULL;
  if (module_exists('regcode')) {
    if (!empty($form_state['values']['expiry_date'])) {
      $expiry_date = strtotime($form_state['values']['expiry_date']);
    }
    elseif (!empty($form_state['values']['expiry_duration'])) {
      $expiry_duration = (int) $form_state['values']['expiry_duration'];
    }
  }
  regcode_roles_create_rule($category, $role, $expiry_date, $expiry_duration);
  drupal_set_message(t('New registration code rule created'));
}