Filter uncanny-learndash-groups

ulgm_show_remaining_total_seats

Filters whether to show the remaining total seats for a managed group, allowing customization of this display.

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

Description

This filter controls whether to display the remaining total seats in the group management interface. Developers can return `false` to hide this information. It fires within the user table actions section when calculating and displaying group enrollment data. The current managed group ID is also passed for context.


Usage

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

Parameters

$ulgm_current_managed_group_id (mixed)
This parameter determines whether to display the total remaining seats for a group.

Return Value

The filtered value.


Examples

<?php
/**
 * Filter to control the display of remaining and total seats information.
 *
 * This function checks if the user has the necessary capabilities to view
 * the remaining and total seat information. If not, it will return false,
 * preventing the display of this information.
 *
 * @param bool $show_remaining_total Whether to show remaining and total seats. Defaults to true.
 * @param int  $group_id The ID of the current managed group.
 * @return bool True if the seats information should be displayed, false otherwise.
 */
add_filter( 'ulgm_show_remaining_total_seats', 'my_custom_ulgm_show_remaining_total_seats', 10, 2 );

function my_custom_ulgm_show_remaining_total_seats( $show_remaining_total, $ulgm_current_managed_group_id ) {
    // Only show the remaining/total seats if the current user has the capability
    // to manage groups or is the administrator.
    if ( current_user_can( 'manage_options' ) || ( isset( $ulgm_current_managed_group_id ) && get_post_field( 'post_author', $ulgm_current_managed_group_id ) === get_current_user_id() ) ) {
        return true;
    }

    // Otherwise, hide the remaining/total seats information.
    return false;
}
?>

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

if ( $seats_quantity ) {
				?>
				<div class="uo-header-subtitle">
					<div class="group-management-total uo-inline">
						<?php echo GroupManagementInterface::$ulgm_management_shortcode['text']['x_users_enrolled']; ?>
					</div>
				</div>
				<?php if ( true === apply_filters( 'ulgm_show_remaining_total_seats', true, GroupManagementInterface::$ulgm_current_managed_group_id ) ) { ?>
				<span class="uo-subtitle-of-h3">
						<span class="group-management-total uo-inline">
							<?php echo GroupManagementInterface::$ulgm_management_shortcode['text']['x_seats_remaining']; ?>
							/ <?php echo GroupManagementInterface::$ulgm_management_shortcode['text']['x_total_seats']; ?>
						</span>
					</span>
					<?php


Scroll to Top