uo_group_completion_time
Filters the group completion time, allowing modification before it's used or displayed.
add_filter( 'uo_group_completion_time', $callback, 10, 3 );
Description
Filters the completion time of a user's group. This hook allows developers to modify the timestamp indicating when a user completed a specific group, useful for custom tracking or reporting. It fires after retrieving the default completion time from user meta.
Usage
add_filter( 'uo_group_completion_time', 'your_function_name', 10, 3 );
Parameters
-
$current_time(mixed) - This parameter contains the current time, which is retrieved from user meta to determine if a group has been completed.
-
$group_id(mixed) - This parameter contains the current completion time for the group, which is retrieved from user meta.
-
$user_id(mixed) - This parameter contains the ID of the group for which the completion time is being calculated.
Return Value
The filtered value.
Examples
add_filter(
'uo_group_completion_time',
function( $current_time, $group_id, $user_id ) {
// Example: If a specific group (e.g., 'advanced-seo') has a manual completion date set,
// override the default user meta value.
if ( 'advanced-seo' === $group_id ) {
// In a real-world scenario, you might fetch this manual date from another option or meta.
// For this example, let's assume a constant or a hardcoded date for demonstration.
$manual_completion_date = '2023-10-26 10:00:00'; // Example manual date
// Convert the manual date to a Unix timestamp.
$manual_timestamp = strtotime( $manual_completion_date );
// If the manual timestamp is valid and earlier than the user meta value (or if user meta is empty),
// use the manual date. This logic might be inverted depending on desired behavior.
if ( $manual_timestamp && ( empty( $current_time ) || $manual_timestamp < $current_time ) ) {
return $manual_timestamp;
}
}
// If no specific override applies, return the original $current_time.
// This allows the core plugin logic to handle fallbacks or the default value.
return $current_time;
},
10, // Priority
3 // Accepted arguments: $current_time, $group_id, $user_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-completion-certificate.php:254
src/classes/group-completion-certificate.php:260
'email' => '',
'msg' => '',
'subject' => '',
);
// External override if required. Usage is in CEU historical records & AT for events ending date.
$current_time = get_user_meta( $user_id, 'group_completed_' . $group_id, true );
self::$current_time_stamp = apply_filters( 'uo_group_completion_time', $current_time, $group_id, $user_id );
// Fallback.
if ( empty( self::$current_time_stamp ) ) {
self::$current_time_stamp = ! empty( $current_time ) ? $current_time : current_time( 'timestamp' );
}
do_action( 'uo_group_completion_time', self::$current_time_stamp, $group_id, $user_id );