You are here

function regcode_roles_admin_submit in Registration codes 7

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

Create the roles.

File

regcode_roles/regcode_roles.module, line 187
Main functionality of regcode_role module.

Code

function regcode_roles_admin_submit($form, $form_state) {
  $role_id = $form_state['values']['role_id'];
  $term_id = $form_state['values']['term_id'];
  $expiry_date = NULL;
  $expiry_duration = NULL;
  if (module_exists('role_expire')) {
    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($term_id, $role_id, $expiry_date, $expiry_duration);
  drupal_set_message(t('New registration code rule created'));
}