ulgm_before_add_invite_form_fields
Fires before the invite form fields are displayed on the user group management page.
add_action( 'ulgm_before_add_invite_form_fields', $callback, 10, 2 );
Description
Fires before the invitation form fields are rendered when adding a user to a group. Developers can use this hook to add custom fields or modify the existing invitation form in the frontend user management interface.
Usage
add_action( 'ulgm_before_add_invite_form_fields', 'your_function_name', 10, 2 );
Parameters
-
$ulgm_current_managed_group_id(mixed) - This parameter contains the ID of the group that is currently being managed.
-
$this(mixed) - This parameter holds the ID of the currently managed group for which the invite form is being displayed.
Examples
/**
* Example function to hook into ulgm_before_add_invite_form_fields.
* This example demonstrates adding a custom field or modifying the form's structure
* before the standard invite form fields are rendered.
*
* @param int|string $ulgm_current_managed_group_id The ID of the current managed group.
* @param object $this The instance of the class where the action is fired.
*/
function my_custom_ulgm_invite_form_fields( $ulgm_current_managed_group_id, $this ) {
// Example: Add a custom field for a specific role selection if the group ID is known.
if ( ! empty( $ulgm_current_managed_group_id ) ) {
?>
<div class="uo-row">
<label for="custom-user-role">
<div class="uo-row__title">
<?php _e( 'Custom User Role', 'my-text-domain' ); ?>
</div>
</label>
<select name="custom-user-role" id="custom-user-role">
<option value="member"><?php _e( 'Member', 'my-text-domain' ); ?></option>
<option value="editor"><?php _e( 'Editor', 'my-text-domain' ); ?></option>
<option value="admin"><?php _e( 'Admin', 'my-text-domain' ); ?></option>
</select>
</div>
<?php
}
// Example: Log that the hook was fired.
error_log( "ulgm_before_add_invite_form_fields action fired for group ID: " . $ulgm_current_managed_group_id );
}
add_action( 'ulgm_before_add_invite_form_fields', 'my_custom_ulgm_invite_form_fields', 10, 2 );
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:466
<?php } ?>
</div>
</div>
<input type="hidden" name="group-id" id="group-id"
value="<?php echo GroupManagementInterface::$ulgm_current_managed_group_id; ?>">
<?php do_action( 'ulgm_before_add_invite_form_fields', GroupManagementInterface::$ulgm_current_managed_group_id, $this ); ?>
<div class="uo-row">
<label for="first-name">
<div class="uo-row__title">
<?php _e( 'First name*', 'uncanny-learndash-groups' ); ?>
</div>
</label>