Action uncanny-learndash-groups

ulgm_before_add_group_leader_form_fields

Fires before the group leader add form fields are displayed, providing the current managed group ID.

add_action( 'ulgm_before_add_group_leader_form_fields', $callback, 10, 1 );

Description

Fires before the group leader add form fields are displayed. Developers can use this hook to add custom fields, modify existing ones, or perform actions before the form is rendered within the modal window. This hook is part of the core ULGm group management functionality.


Usage

add_action( 'ulgm_before_add_group_leader_form_fields', 'your_function_name', 10, 1 );

Parameters

$ulgm_current_managed_group_id (mixed)
This parameter contains the ID of the group for which a group leader is being added.

Examples

/**
 * Example function to add custom fields before the add group leader form.
 * This function demonstrates how to hook into 'ulgm_before_add_group_leader_form_fields'
 * to inject additional input fields into the group leader addition form.
 *
 * @param int $ulgm_current_managed_group_id The ID of the group for which a leader is being added.
 */
function my_custom_group_leader_fields( $ulgm_current_managed_group_id ) {
	// Only proceed if we have a valid group ID.
	if ( ! empty( $ulgm_current_managed_group_id ) && is_numeric( $ulgm_current_managed_group_id ) ) {
		?>
		<div class="uo-row">
			<label for="custom-leader-role">
				<div class="uo-row__title">
					<?php esc_html_e( 'Custom Leader Role', 'your-text-domain' ); ?>
				</div>
			</label>
			<input type="text" id="custom-leader-role" name="custom_leader_role" value="" />
			<p class="uo-row__description"><?php esc_html_e( 'Enter a specific role for this group leader.', 'your-text-domain' ); ?></p>
		</div>

		<div class="uo-row">
			<label for="leader-notes">
				<div class="uo-row__title">
					<?php esc_html_e( 'Leader Notes', 'your-text-domain' ); ?>
				</div>
			</label>
			<textarea id="leader-notes" name="leader_notes" rows="4"></textarea>
			<p class="uo-row__description"><?php esc_html_e( 'Add any relevant notes about this group leader.', 'your-text-domain' ); ?></p>
		</div>

		<input type="hidden" name="managed_group_id" value="<?php echo esc_attr( $ulgm_current_managed_group_id ); ?>" />
		<?php
	}
}
add_action( 'ulgm_before_add_group_leader_form_fields', 'my_custom_group_leader_fields', 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/groups-table-actions.php:28

rel="modal:open"><?php echo self::$ulgm_management_shortcode['text']['add_group_leader']; ?></button>

					<div id="group-management-add-group-leader" class="group-management-modal" style="display:none;">
						<div class="uo-groups">
							<div class="group-management-form">
								<div class="group-management-rest-message"></div>

								<?php do_action( 'ulgm_before_add_group_leader_form_fields', self::$ulgm_current_managed_group_id ); ?>

								<div class="uo-row">
									<label for="first-name">
										<div class="uo-row__title">
											<?php echo __( 'First name*', 'uncanny-learndash-groups' ); ?>
										</div>
									</label>


Scroll to Top