ulgm_after_add_invite_form_fields
Fires after invite form fields are added, allowing for custom modifications to the group invite form.
add_action( 'ulgm_after_add_invite_form_fields', $callback, 10, 2 );
Description
Fires after the password field is displayed on the "Add User" form within Uncanny Groups. Developers can use this action to add custom fields or modify existing ones before the form is submitted. It provides the current managed group ID and the form object for context.
Usage
add_action( 'ulgm_after_add_invite_form_fields', 'your_function_name', 10, 2 );
Parameters
-
$ulgm_current_managed_group_id(mixed) - This parameter contains the ID of the currently managed group to which the invitation form is being added.
-
$this(mixed) - This parameter holds the ID of the currently managed group for which an invitation form is being displayed.
Examples
/**
* Example of how to hook into ulgm_after_add_invite_form_fields.
* This example adds an optional text field for a custom user identifier.
*
* @param int $ulgm_current_managed_group_id The ID of the group currently being managed.
* @param object $this The instance of the class where the action is being fired.
*/
add_action( 'ulgm_after_add_invite_form_fields', function ( $ulgm_current_managed_group_id, $this_obj ) {
// Check if the current group ID is valid.
if ( ! absint( $ulgm_current_managed_group_id ) ) {
return;
}
// Render an additional field for a custom user identifier.
?>
<div class="uo-row">
<label class="uo-label" for="custom_user_identifier"><?php _e( 'Custom User Identifier (Optional)', 'uncanny-learndash-groups' ); ?></label>
<input class="uo-input" type="text" name="custom_user_identifier" id="custom_user_identifier" value="">
<div class="uo-row__description">
<?php _e( 'Enter a unique identifier for the user if needed for external systems.', 'uncanny-learndash-groups' ); ?>
</div>
</div>
<?php
}, 10, 2 ); // Priority 10, accepts 2 arguments.
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/users-table-actions.php:522
<input class="uo-input" type="text" name="uo_password" id="password"
value="">
<div class="uo-row__description">
<?php _e( 'Set an optional password for new users. If no password is entered, a random password will be generated. If the user already exists, the user's password will not be changed and this value will be ignored.', 'uncanny-learndash-groups' ); ?>
</div>
</div>
<?php do_action( 'ulgm_after_add_invite_form_fields', GroupManagementInterface::$ulgm_current_managed_group_id, $this ); ?>
<div class="uo-row-footer">
<div style="margin-bottom: 15px" class="uo-modal-spinner"></div>
<button class="uo-btn submit-group-management-form"
data-end-point="add_user"><?php _e( 'Add user', 'uncanny-learndash-groups' ); ?></button>
</div>
</form>