Filter uncanny-learndash-groups

ulgm_show_show_remove_group_leader_button

Filters whether the remove group leader button should be displayed on a group.

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

Description

Filters whether to display the "Remove Group Leader" button. Developers can return `false` to hide this button for specific groups or users. This hook is applied before the button is rendered in the group management interface.


Usage

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

Return Value

The filtered value.


Examples

add_filter(
	'ulgm_show_show_remove_group_leader_button',
	'my_custom_ulgm_hide_remove_leader_button',
	10,
	2
);

/**
 * Conditionally hide the "Remove Group Leader" button.
 *
 * This function hooks into the 'ulgm_show_show_remove_group_leader_button'
 * filter to control the visibility of the "Remove Group Leader" button.
 * It will hide the button if the current managed group ID is '123'.
 *
 * @param bool $show_button  The default value for showing the button (true).
 * @param int  $group_id     The ID of the currently managed group.
 * @return bool Whether to show the "Remove Group Leader" button.
 */
function my_custom_ulgm_hide_remove_leader_button( $show_button, $group_id ) {
	// Let's say we want to hide the button for a specific group, for example, group ID '123'.
	if ( $group_id === 123 ) {
		return false; // Hide the button.
	}

	// Otherwise, return the default value (or whatever the previous filters decided).
	return $show_button;
}

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:92

</div>

				<?php } ?>

				<div class="group-leader-management-buttons uo-hidden">

					<?php if ( true === apply_filters( 'ulgm_show_show_remove_group_leader_button', true, self::$ulgm_current_managed_group_id ) ) : ?>
						<!-- Remove Group Leaders -->
						<button class="uo-btn uo-left ulgm-modal-link" data-modal-id="#group-management-remove-group-leader"
								rel="modal:open"><?php echo self::$ulgm_management_shortcode['text']['remove_group_leader']; //phpcs:ignore ?></button>

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


Scroll to Top