Filter uncanny-toolkit-pro

uo_drip_ignore_learndash_release_date

Filters whether LearnDash release dates are ignored for drip content, allowing custom control over content availability.

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

Description

Allows developers to override LearnDash lesson/topic release date checks within Uncanny Automator. By default, this filter returns `false`. Modify it to `true` to bypass LearnDash's built-in release date restrictions, enabling content to be dripped regardless of its scheduled availability in LearnDash. This hook fires before checking LearnDash access.


Usage

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

Parameters

$args (mixed)
This parameter is a boolean value that, when set to `true`, allows LearnDash's built-in access from date to override the Uncanny Automator drip settings.

Return Value

The filtered value.


Examples

<?php
/**
 * When enabled, this filter will allow LearnDash's built-in lesson/topic release dates
 * to be ignored, effectively overriding them with Uncanny Drip's group drip settings.
 *
 * By default, if a LearnDash release date is set and is in the past, it will be used.
 * Setting this filter to true will make Uncanny Drip prioritize its group drip dates
 * even if a LearnDash release date is available.
 *
 * @param bool $allow_ld_override Whether to ignore LearnDash's release date. Defaults to false.
 * @param array $args An array of arguments passed to the filter, including:
 *                    - lesson_id: The ID of the lesson or topic.
 *                    - course_id: The ID of the course.
 *                    - ld_access_from: The LearnDash access date timestamp.
 *                    - user_id: The ID of the current user.
 *                    - group_drip: The calculated drip date for the user's group.
 * @return bool True to ignore LearnDash's release date and use the group drip date, false otherwise.
 */
add_filter( 'uo_drip_ignore_learndash_release_date', function( $allow_ld_override, $args ) {
    // Example scenario: Always ignore LearnDash release dates for a specific course
    // For instance, course ID 123 should always use group drip settings.
    if ( isset( $args['course_id'] ) && 123 === $args['course_id'] ) {
        return true; // Always ignore LearnDash release date for this course
    }

    // Another example: Ignore LearnDash release dates if the user is part of a specific group.
    // Let's assume group ID 456 requires ignoring LearnDash dates.
    // You'd likely need to check user's group memberships here. For demonstration,
    // we'll simulate checking if $args['group_drip'] indicates a specific group logic.
    // In a real scenario, you would fetch user group memberships.
    // For this example, let's pretend $args['group_drip'] contains a special marker
    // if the user is in group 456.
    if ( isset( $args['user_id'] ) && isset( $args['group_drip'] ) && 'special_group_456_drip' === $args['group_drip'] ) {
         return true; // Ignore LearnDash release date for users in group 456
    }

    // By default, stick to the original behavior if none of the above conditions are met.
    return $allow_ld_override;
}, 10, 2 );

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/uncanny-drip-topics-by-group.php:650
src/classes/uncanny-drip-lessons-by-group.php:646

$args              = array(
							'lesson_id'      => $topic_id,
							'course_id'      => $course_id,
							'ld_access_from' => $ld_access,
							'user_id'        => $user_id,
							'group_drip'     => $group_dates[ $group_id ],
						);
						$allow_ld_override = apply_filters( 'uo_drip_ignore_learndash_release_date', false, $args );
						if ( self::is_timestamp( $ld_access ) && false === $allow_ld_override ) {
							$return = $ld_access;
						} else {
							if ( $return_timestamp ) {
								return $group_dates[ $group_id ];
							}

Scroll to Top