Filter uncanny-learndash-groups

ulgm_add_invite_checked

Filters whether a new user invite is marked as checked before being processed.

add_filter( 'ulgm_add_invite_checked', $callback, 10, 1 );

Description

This filter hook controls whether the "Add User" checkbox is pre-checked in group management. Developers can return `false` to uncheck it by default, or any other mixed value to maintain the default `true` state.


Usage

add_filter( 'ulgm_add_invite_checked', 'your_function_name', 10, 1 );

Return Value

The filtered value.


Examples

/**
 * Example: Conditionally set the "invite checked" status based on user role.
 *
 * This filter hook determines whether the "invite user" checkbox should be
 * pre-checked when displaying the add user modal.
 *
 * @param bool $checked The current checked status (default is true).
 * @return bool The new checked status.
 */
add_filter( 'ulgm_add_invite_checked', function( $checked ) {
	// Only pre-check the invite option if the current user is an administrator.
	if ( current_user_can( 'manage_options' ) ) {
		return true;
	}
	return false;
}, 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/users-table-actions.php:425

<?php } ?>
					<?php } ?>

					<?php if ( $populate_management_features ) { ?>

						<?php
						if ( $add_user_button ) {
							$checked  = apply_filters( 'ulgm_add_invite_checked', true );
							$selected = $checked ? ' checked="checked"' : '';
							?>
							<!-- Add Users Modal box -->
							<div id="group-management-add-user" class="group-management-modal" style="display:none;">

								<div class="uo-groups">
									<div class="group-management-form">

Scroll to Top