Filter uncanny-learndash-groups

ulgm_group_management_invited_user_status_id

Filters the status ID for an invited user before they are enrolled in a group.

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

Description

Filters the status ID for users invited to a group. Developers can modify the default 'not-enrolled' status to customize how invited users are displayed or processed. This hook provides flexibility in managing user enrollment states within group management.


Usage

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

Parameters

$user (mixed)
This parameter represents the initial status for users who have been invited but have not yet enrolled in the group.
$group_id (mixed)
This parameter provides the user object for the current user being processed.

Return Value

The filtered value.


Examples

<?php
/**
 * Example of how to use the ulgm_group_management_invited_user_status_id filter hook.
 *
 * This filter allows you to modify the status ID for invited users who are not yet enrolled
 * in a group. For instance, you might want to change the ID to a more specific one
 * if there are different types of "not enrolled" states.
 *
 * @param string $status_id The default status ID ('not-enrolled').
 * @param WP_User $user     The user object.
 * @param int    $group_id  The ID of the group.
 * @return string The modified status ID.
 */
add_filter( 'ulgm_group_management_invited_user_status_id', function( $status_id, $user, $group_id ) {
    // Example: If the user has a specific custom field indicating they were invited
    // but haven't accepted yet, we might want to use a different status ID.
    // For this example, let's assume a custom field '_invitation_status' exists.

    $invitation_status = get_user_meta( $user->ID, '_invitation_status', true );

    if ( $invitation_status === 'pending_acceptance' ) {
        return 'pending-invitation'; // A more specific status ID
    }

    // Otherwise, return the original status ID.
    return $status_id;
}, 10, 3 ); // Priority 10, accepts 3 arguments: $status_id, $user, $group_id
?>

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

self::$ulgm_enrolled_users_data_dt[] = (object) array(
				'check'      => self::table_checkbox( $key ),
				'first_name' => $f,
				'last_name'  => $l,
				'email'      => '<a href="mailto:' . $email . '" class="edit_assignment groups-email-mailto-link">' . $email . '</a>',
				'status'     => apply_filters( 'ulgm_group_management_invited_user_status', '<div class="status status-not-enrolled" data-status="not-enrolled">' . __( 'Not Enrolled', 'uncanny-learndash-groups' ) . '</div>', $user, $group_id ),
				'status_id'  => apply_filters( 'ulgm_group_management_invited_user_status_id', 'not-enrolled', $user, $group_id ),
				'key'        => $key,
				'id'         => null,
			);
		}

		self::$ulgm_enrolled_users_data_dt = apply_filters_deprecated( 'ulgm_enrolled_user_data', array( self::$ulgm_enrolled_users_data_dt ), '4.2.1', 'ulgm_group_management_enrolled_user_data' );
		self::$ulgm_enrolled_users_data_dt = apply_filters( 'ulgm_group_management_enrolled_user_data', self::$ulgm_enrolled_users_data_dt, $group_id, $args );


Scroll to Top