function _notify_user_reg_fields in Notify 2.0.x
Same name and namespace in other branches
- 8 notify.module \_notify_user_reg_fields()
- 6 notify.module \_notify_user_reg_fields()
- 7 notify.module \_notify_user_reg_fields()
- 1.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 481 - Hooks for Notify module.
Code
function _notify_user_reg_fields() {
$config = \Drupal::config('notify.settings');
if (!\Drupal::currentUser()
->hasPermission('access notify')) {
return [];
}
// 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'] = [
'#weight' => $config
->get('notify_weightur'),
'#type' => 'fieldset',
'#title' => t('E-mail Notifications'),
];
// Add the checkbox to the fieldset.
$fields['notify_agree']['notify_decision'] = [
'#type' => 'checkbox',
'#title' => t('Receive e-mail notifications of new content posted to this site. Notifications are sent every @interval.', [
'@interval' => \Drupal::service('date.formatter')
->formatInterval($period),
]),
'#return_value' => 1,
'#default_value' => $config
->get('notify_reg_default'),
];
return $fields;
}