Filter uncanny-learndash-groups

ulgm_populate_management_features

Filters the management features populated for a specific managed group, allowing customization before display.

add_filter( 'ulgm_populate_management_features', $callback, 10, 2 );

Description

Filter the management features for a group, allowing developers to add, remove, or modify options presented in the group management interface. This hook fires before the management features are displayed. Developers can use this to customize user roles and permissions within groups.


Usage

add_filter( 'ulgm_populate_management_features', 'your_function_name', 10, 2 );

Parameters

$populate_management_features (mixed)
This parameter contains an array of management features that are being populated for the current user group.
$ulgm_current_managed_group_id (mixed)
This parameter holds the data structure that defines the management features available for groups, which can be modified by the filter.

Return Value

The filtered value.


Examples

/**
 * Example of how to use the ulgm_populate_management_features filter.
 *
 * This filter allows you to conditionally prevent the population of management features
 * for a group based on custom logic. For instance, you might want to disable
 * certain features if the group is a child group and a specific query parameter is present.
 *
 * @param mixed $populate_management_features The current value determining if management features should be populated.
 * @param mixed $ulgm_current_managed_group_id The ID of the currently managed group.
 * @return mixed The modified value for $populate_management_features.
 */
add_filter( 'ulgm_populate_management_features', 'my_custom_ulgm_populate_management_features', 10, 2 );

function my_custom_ulgm_populate_management_features( $populate_management_features, $ulgm_current_managed_group_id ) {
	// Example: If the current group is a specific type of group (e.g., an archive group)
	// and we are viewing it in a context where certain administrative actions
	// should be hidden, we can set $populate_management_features to false.
	// In a real-world scenario, you'd replace 'is_archive_group' with your actual condition check.

	// Replace this with your actual logic to determine if management features should be populated.
	// For demonstration, let's say we want to disable management features for a specific group ID.
	$specific_group_id_to_disable_features = 123; // Replace with a real group ID if needed for testing.

	if ( $ulgm_current_managed_group_id === $specific_group_id_to_disable_features ) {
		// Disable management features for this specific group.
		return false;
	}

	// If the original logic in the plugin should still apply, return its value.
	// If you are completely replacing the logic, you can return your own value.
	return $populate_management_features;
}

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:143
src/classes/group-management/group-management-interface.php:1219

<?php
	$populate_management_features = GroupManagementInterface::$populate_management_features;
	if ( function_exists( 'learndash_is_groups_hierarchical_enabled' ) && learndash_is_groups_hierarchical_enabled() && 'yes' === get_option( 'ld_hierarchy_settings_child_groups', 'no' ) ) {
		if ( ulgm_filter_has_var( 'show-children' ) ) {
			$populate_management_features = false;
		}
	}
	$populate_management_features = apply_filters( 'ulgm_populate_management_features', $populate_management_features, GroupManagementInterface::$ulgm_current_managed_group_id );
	if ( $populate_management_features ) {
		?>
<div class="uo-row uo-groups-section uo-groups-enrolled-users">
	<div class="uo-row uo-header">
		<h2 class="group-table-heading uo-looks-like-h3"><?php _e( 'Enrolled users', 'uncanny-learndash-groups' ); ?></h2>
		<div class="uo-row uo-header-subtitle">
			<?php


Scroll to Top