ulgm_add_invite_user_first_name_required
Filters the requirement for the first name field when inviting users to a managed group.
add_filter( 'ulgm_add_invite_user_first_name_required', $callback, 10, 1 );
Description
Filters whether the "First name" field is required when inviting a new user to a group. Return `true` to make it required, or `false` to make it optional. The current group ID is also passed for contextual filtering.
Usage
add_filter( 'ulgm_add_invite_user_first_name_required', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
<?php
/**
* Example: Make the first name field required only for specific groups.
*
* This filter hook controls whether the 'First name' field is marked as required
* when inviting a user to a group. By default, it's required.
* This example makes it optional for a specific group ID (e.g., group ID 123).
*
* @param bool $is_required Whether the first name field is currently required.
* @param int $group_id The ID of the group being managed.
* @return bool True if the field should be required, false otherwise.
*/
add_filter( 'ulgm_add_invite_user_first_name_required', function ( $is_required, $group_id ) {
// Define the group IDs for which the first name should NOT be required.
$optional_first_name_groups = array( 123, 456 ); // Replace with actual group IDs.
if ( in_array( $group_id, $optional_first_name_groups, true ) ) {
return false; // First name is optional for these groups.
}
// For all other groups, maintain the default requirement.
return $is_required;
}, 10, 2 ); // 10 is the priority, 2 is the number of arguments accepted by the callback.
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:475
<div class="uo-row">
<label for="first-name">
<div class="uo-row__title">
<?php _e( 'First name*', 'uncanny-learndash-groups' ); ?>
</div>
</label>
<input class="uo-input"
<?php if ( true === apply_filters( 'ulgm_add_invite_user_first_name_required', true, GroupManagementInterface::$ulgm_current_managed_group_id ) ) { ?>
required="required"
<?php } ?>
type="text"
name="first_name"
id="first-name"
value="">
</div>