You are here

function _notify_user_reg_fields in Notify 1.0.x

Same name and namespace in other branches
  1. 8 notify.module \_notify_user_reg_fields()
  2. 6 notify.module \_notify_user_reg_fields()
  3. 7 notify.module \_notify_user_reg_fields()
  4. 2.0.x notify.module \_notify_user_reg_fields()

Returns form fields to be added to User Regsitration form.

1 call to _notify_user_reg_fields()
notify_form_user_register_form_alter in ./notify.module
Implements hook_form_FORM_ID_alter().

File

./notify.module, line 434
Notify module sends e-mail digests of new content and comments.

Code

function _notify_user_reg_fields() {
  $config = \Drupal::config('notify.settings');
  if (!\Drupal::currentUser()
    ->hasPermission('access notify')) {
    return array();
  }

  // Get the variable for how often the notifications are sent out.
  $period = $config
    ->get("notify_period");

  // Add a fieldset containing a checkbox for users to accept getting updates on
  // the registration form.
  $fields['notify_agree'] = array(
    '#weight' => $config
      ->get('notify_weightur'),
    '#type' => 'fieldset',
    '#title' => t('E-mail Notifications'),
  );

  // Add the checkbox to the fieldset.
  $fields['notify_agree']['notify_decision'] = array(
    '#type' => 'checkbox',
    '#title' => t('Receive e-mail notifications of new content posted to this site. Notifications are sent every @interval.', array(
      '@interval' => \Drupal::service('date.formatter')
        ->format($period),
    )),
    '#return_value' => 1,
    '#default_value' => $config
      ->get('notify_reg_default'),
  );
  return $fields;
}