ulgm_before_add_bulk_users_form_fields
Fires before the bulk user add form fields are displayed, passing the current managed group ID.
add_action( 'ulgm_before_add_bulk_users_form_fields', $callback, 10, 1 );
Description
Fires before bulk user addition form fields are displayed for a specific managed group. Developers can use this hook to inject custom fields, modify existing ones, or add dynamic elements before the default form fields are rendered, allowing for enhanced user management capabilities.
Usage
add_action( 'ulgm_before_add_bulk_users_form_fields', 'your_function_name', 10, 1 );
Parameters
-
$ulgm_current_managed_group_id(mixed) - This parameter contains the ID of the current managed group to which users are being added.
Examples
<?php
/**
* Add a custom field before the bulk user add form fields.
* This example adds a custom 'phone' field for each user being added.
*
* @param int|string $ulgm_current_managed_group_id The ID of the group the users are being added to.
*/
function my_custom_ulgm_phone_field( $ulgm_current_managed_group_id ) {
// Only add the field if we have a valid group ID.
if ( ! empty( $ulgm_current_managed_group_id ) ) {
?>
<div class="content-leaders-phone uo-table-cell uo-table-cell-2">
<input class="uo-input" type="tel" name="phone[]" value="" placeholder="<?php esc_attr_e( 'Phone Number', 'my-custom-plugin' ); ?>">
</div>
<?php
}
}
add_action( 'ulgm_before_add_bulk_users_form_fields', 'my_custom_ulgm_phone_field', 10, 1 );
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/templates/frontend-uo_groups/add-users.php:78
<?php $j = 1; ?>
<?php while ( $j <= $remaining ) { ?>
<div class="uo-row uo-table-content uo-tbl-item body-row ulgm-table-row-flex">
<div class="content-leaders-select uo-table-cell uo-table-cell-0_5">
<?php echo $j; ?>.
</div>
<?php do_action( 'ulgm_before_add_bulk_users_form_fields', self::$ulgm_current_managed_group_id ); ?>
<div class="content-leaders-first-name uo-table-cell uo-table-cell-2">
<input class="uo-input" type="text" name="first_name[]" value="" placeholder="<?php echo __( 'First name', 'uncanny-learndash-groups' ); ?>">
</div>
<div class="content-leaders-last-name uo-table-cell uo-table-cell-2">
<input class="uo-input" type="text" name="last_name[]" value="" placeholder="<?php echo __( 'Last name', 'uncanny-learndash-groups' ); ?>">
</div>