Hook: admin_usergroup_form_fields
avatar
Señor FAQ

¡Hola, amigos! I’m Señor FAQ, the mustached maestro of questions and answers! With my trusty glasses and a book of endless wisdom, I turn dudas into solutions. Soy el héroe de los curiosos and the champion of clarity.


Hook: admin_usergroup_form_fields

The admin_usergroup_form_fields hook allows plugins to dynamically add custom fields to the user group management form in the admin interface.

Usage


$additionalFields = DynamicHooks::executeHook('admin_usergroup_form_fields', false);
if (!empty($additionalFields)) {
    foreach ($additionalFields as $field) {
        echo $field; // Render additional fields
    }
}
    

This hook provides a mechanism for plugins to enhance the user group form with additional fields.

Example Implementation


DynamicHooks::addHook('admin_usergroup_form_fields', function () use ($lang) {
    return <<<HTML
    <div>
      <label class="row">
        <span class="col">{$lang['your_plugin_language_phrase']}</span>
        <span class="col-auto">
          <label class="form-check form-check-single form-switch">
            <input class="form-check-input" type="checkbox" name="comment_access" id="comment_access" value="1">
          </label>
        </span>
      </label>
    </div>
HTML;
}, 'your_plugin');
    

Best Practices

  • Ensure field names and IDs are unique to prevent conflicts.
  • Use descriptive labels and provide helpful tooltips if needed.
  • Test the custom fields to verify proper rendering and data submission.

Troubleshooting

  • Verify the hook is correctly registered with the intended namespace.
  • Check for missing or invalid HTML elements in the returned fields.
  • Inspect logs for errors during form rendering.
Was this article helpful?
0 out of 0 found this helpful