You are here

function social_user_ensure_help_text_fieldset in Open Social 8.4

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_user/social_user.module \social_user_ensure_help_text_fieldset()
  2. 8.3 modules/social_features/social_user/social_user.module \social_user_ensure_help_text_fieldset()
  3. 8.5 modules/social_features/social_user/social_user.module \social_user_ensure_help_text_fieldset()
  4. 8.6 modules/social_features/social_user/social_user.module \social_user_ensure_help_text_fieldset()
  5. 8.7 modules/social_features/social_user/social_user.module \social_user_ensure_help_text_fieldset()
  6. 8.8 modules/social_features/social_user/social_user.module \social_user_ensure_help_text_fieldset()
  7. 10.3.x modules/social_features/social_user/social_user.module \social_user_ensure_help_text_fieldset()
  8. 10.0.x modules/social_features/social_user/social_user.module \social_user_ensure_help_text_fieldset()
  9. 10.1.x modules/social_features/social_user/social_user.module \social_user_ensure_help_text_fieldset()
  10. 10.2.x modules/social_features/social_user/social_user.module \social_user_ensure_help_text_fieldset()

Ensures that the form contains a `user_help_texts` fieldset.

The fieldset is targetted to be positioned after the registration_cancellation element of the account settings form. If the target can't be found then the fieldset is appended to the end. If the fieldset has already been added then nothing happens.

Return value

string The key of the fieldset that was added.

2 calls to social_user_ensure_help_text_fieldset()
social_user_form_user_admin_settings_alter in modules/social_features/social_user/social_user.module
Implements hook_form_FORM_ID_alter().
_social_auth_extra_help_text_config_form in modules/custom/social_auth_extra/social_auth_extra.module
Adds the form fields to configure the social signup/login user help texts.

File

modules/social_features/social_user/social_user.module, line 604
The social user module alterations.

Code

function social_user_ensure_help_text_fieldset(&$form) {
  $key = 'user_help_texts';
  if (in_array($key, array_keys($form))) {
    return $key;
  }
  $fieldset = [
    '#type' => 'details',
    '#open' => TRUE,
    '#title' => new TranslatableMarkup("Login and Registration help texts"),
    '#description' => new TranslatableMarkup("These fields allow you to configure various help texts that are shown to users during signup and login"),
  ];

  // Insert the fieldset after the registration and cancellation settings.
  $index = array_search("registration_cancellation", array_keys($form));
  if ($index !== FALSE && $index !== count($form)) {
    $form = array_slice($form, 0, $index + 1, TRUE) + [
      $key => $fieldset,
    ] + array_slice($form, $index + 1, NULL, TRUE);
  }
  else {

    // Fallback to end of array appending if we can't find our target key.
    $form[$key] = $fieldset;
  }
  return $key;
}