ulgm_group_management_enrolled_user_status_id
Filters the status ID for an enrolled user, allowing modification based on user, group, and course completion data.
add_filter( 'ulgm_group_management_enrolled_user_status_id', $callback, 10, 6 );
Description
Filters the enrollment status ID for a user within a LearnDash group. Developers can modify the status ID to represent different enrollment states, like 'active', 'pending', or 'completed', based on user, group, and course completion data. This allows for custom enrollment status logic and display.
Usage
add_filter( 'ulgm_group_management_enrolled_user_status_id', 'your_function_name', 10, 6 );
Parameters
-
$status_id(mixed) - This parameter represents the current status ID of the enrolled user in the group.
-
$status(mixed) - This parameter represents the current status ID of the enrolled user within the group management system.
-
$user(mixed) - This parameter provides the human-readable status of the user's enrollment in the group.
-
$group_id(mixed) - This parameter contains information about the user who is enrolled in the group.
-
$learndash_group_enrolled_courses(mixed) - This parameter represents the ID of the group the user is currently enrolled in.
-
$completions_rearranged(mixed) - This parameter contains an array of courses that the user is currently enrolled in within a LearnDash group.
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to filter the status ID for an enrolled user in LearnDash Group Management.
* This example would change the status ID to a custom value if the user has completed
* a specific course within the group.
*
* @param mixed $status_id The original status ID.
* @param mixed $status The status string (e.g., 'Completed', 'Not Started').
* @param WP_User $user The WP_User object of the enrolled user.
* @param int $group_id The ID of the group.
* @param array $learndash_group_enrolled_courses Array of LearnDash course IDs enrolled in the group.
* @param array $completions_rearranged Array of user course completion data, rearranged.
* @return mixed The modified or original status ID.
*/
function my_custom_ulgm_enrolled_user_status_id_filter( $status_id, $status, $user, $group_id, $learndash_group_enrolled_courses, $completions_rearranged ) {
// Define a custom status ID for a specific completion scenario.
$custom_completed_status_id = 10;
// Check if the user has completed a specific course within the group.
// For demonstration, let's assume 'some_specific_course_id' is the ID of a course
// that signifies a special completion status.
$some_specific_course_id = 123;
// Check if the user has completed the specific course.
// The structure of $completions_rearranged is assumed based on typical LearnDash grouping.
// You might need to inspect the actual structure of this variable in your environment.
if ( isset( $completions_rearranged[ $user->ID ] ) && is_array( $completions_rearranged[ $user->ID ] ) ) {
foreach ( $completions_rearranged[ $user->ID ] as $course_id => $completion_data ) {
// Check if the course ID matches our specific course and if it's marked as completed.
if ( (int) $course_id === $some_specific_course_id && $completion_data['status'] === 'completed' ) {
// If the specific course is completed, override the status ID.
return $custom_completed_status_id;
}
}
}
// If the specific condition isn't met, return the original status ID.
return $status_id;
}
add_filter( 'ulgm_group_management_enrolled_user_status_id', 'my_custom_ulgm_enrolled_user_status_id_filter', 10, 6 );
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:1050
'ulgm_group_management_enrolled_user_info',
(object) array(
'check' => self::table_checkbox( $user->ID ),
'first_name' => self::user_edit_link( $f, 'first_name', $user->ID ),
'last_name' => self::user_edit_link( $l, 'last_name', $user->ID ),
'email' => '<a href="mailto:' . $email . '" class="edit_assignment groups-email-mailto-link">' . $email . '</a>',
'status' => $status,
'status_id' => apply_filters( 'ulgm_group_management_enrolled_user_status_id', $status_id, $status, $user, $group_id, $learndash_group_enrolled_courses, $completions_rearranged ),
'key' => $key,
'id' => $user->ID,
),
$group_id,
$user,
$learndash_group_enrolled_courses
);