You are here

function user_limit_form_user_admin_settings_alter in User Limit 7

Same name and namespace in other branches
  1. 6 user_limit.module \user_limit_form_user_admin_settings_alter()

Implements hook_FORM_ID_alter().

Add settings to the user_admin_settings form.

File

./user_limit.module, line 57
The User Limit module limits the number of users that can be registered on a Drupal site.

Code

function user_limit_form_user_admin_settings_alter(&$form, &$form_state) {
  $limit_is_default = variable_get('user_limit', 0) == 0;
  $uid1_is_default = variable_get('user_limit_uid1', 0) == 0;
  $active_is_default = variable_get('user_limit_active', 0) == 0;
  $message_is_default = variable_get('user_limit_message', USER_LIMIT_DEFAULT_MESSAGE) == USER_LIMIT_DEFAULT_MESSAGE;
  $all_options_default = $limit_is_default && $uid1_is_default && $active_is_default && $message_is_default;
  $form['registration_cancellation']['user_limit'] = array(
    '#type' => 'fieldset',
    '#title' => t('User limit'),
    '#collapsible' => TRUE,
    '#collapsed' => $all_options_default,
  );
  $form['registration_cancellation']['user_limit']['user_limit'] = array(
    '#type' => 'textfield',
    '#title' => t('User limit'),
    '#default_value' => variable_get('user_limit', 0),
    '#description' => t('Limit the total number of users that can be created on the site. Set to 0 for unlimited.'),
    '#element_validate' => array(
      'user_limit_validate',
    ),
  );
  $form['registration_cancellation']['user_limit']['user_limit_uid1'] = array(
    '#type' => 'checkbox',
    '#title' => t('Count UID1 towards user limit'),
    '#default_value' => variable_get('user_limit_uid1', 0),
    '#description' => t('Include UID1 in the count for the user limit for the site.'),
  );
  $form['registration_cancellation']['user_limit']['user_limit_active'] = array(
    '#type' => 'checkbox',
    '#title' => t('Only count active users'),
    '#default_value' => variable_get('user_limit_active', 0),
    '#description' => t('Exclude banned or canceled users from the limit for the site.'),
  );
  $form['registration_cancellation']['user_limit']['user_limit_show_counts'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show counts on user registration page'),
    '#default_value' => variable_get('user_limit_show_counts', 0),
    '#description' => t('Show the current number of users and the limit on the user registration page.'),
  );
  $form['registration_cancellation']['user_limit']['user_limit_message'] = array(
    '#type' => 'textarea',
    '#title' => t('Limit surpassed message'),
    '#default_value' => variable_get('user_limit_message', USER_LIMIT_DEFAULT_MESSAGE),
    '#description' => t('Message to display on user registration page if user limit is reached.'),
  );
}