ulgm_after_add_bulk_users_form_fields
Fires after the bulk users form fields are added, providing access to the current managed group ID.
add_action( 'ulgm_after_add_bulk_users_form_fields', $callback, 10, 1 );
Description
Fires after the email and password fields are displayed on the bulk user add form. Developers can use this hook to add custom fields or modify the existing form structure for bulk user additions within a group. No specific caveats are noted for this hook.
Usage
add_action( 'ulgm_after_add_bulk_users_form_fields', 'your_function_name', 10, 1 );
Parameters
-
$ulgm_current_managed_group_id(mixed) - This parameter holds the ID of the group currently being managed, which is relevant when adding users to a specific group.
Examples
<?php
/**
* Example function to add custom fields after the default bulk user add fields.
* This function might add a dropdown for user roles or a field for custom metadata.
*
* @param int|string $ulgm_current_managed_group_id The ID of the group currently being managed.
*/
function my_custom_ulgm_bulk_user_fields( $ulgm_current_managed_group_id ) {
// This is a placeholder. In a real scenario, you might fetch group-specific settings.
$group_id = intval( $ulgm_current_managed_group_id );
// Example: Add a simple text field to assign a specific tag to newly added users.
?>
<div class="content-leaders-user-tag uo-table-cell uo-table-cell-2">
<input class="uo-input" type="text" name="user_tag[]" value="" placeholder="<?php echo __( 'User Tag (Optional)', 'my-text-domain' ); ?>">
</div>
<?php
// You could also add more complex elements, like a select dropdown for roles:
/*
$roles = wp_roles()->get_names();
?>
<div class="content-leaders-user-role uo-table-cell uo-table-cell-2">
<select name="user_role[]" class="uo-select">
<option value=""><?php esc_html_e( 'Select Role', 'my-text-domain' ); ?></option>
<?php foreach ( $roles as $role_slug => $role_name ) : ?>
<option value="<?php echo esc_attr( $role_slug ); ?>"><?php echo esc_html( $role_name ); ?></option>
<?php endforeach; ?>
</select>
</div>
<?php
*/
}
// Hook the function into the 'ulgm_after_add_bulk_users_form_fields' action.
// The '3' indicates that this function should run after other functions hooked at the default priority.
// The '1' indicates that this function accepts one argument.
add_action( 'ulgm_after_add_bulk_users_form_fields', 'my_custom_ulgm_bulk_user_fields', 3, 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:93
<div class="content-leaders-email uo-table-cell uo-table-cell-3_5">
<input class="uo-input" type="email" name="email[]" value="" placeholder="<?php echo __( 'Email', 'uncanny-learndash-groups' ); ?>">
</div>
<div class="content-leaders-password uo-table-cell uo-table-cell-2">
<input class="uo-input" type="text" name="uo_password[]" value="" placeholder="<?php echo __( 'Password', 'uncanny-learndash-groups' ); ?>">
</div>
<?php do_action( 'ulgm_after_add_bulk_users_form_fields', self::$ulgm_current_managed_group_id ); ?>
</div>
<?php
$j ++;
if ( $j > 25 ) {
break;
}
}