Browse: Home / Snippets /

Bypass drip logic if user enrolled in group

Contents


Snippet #

add_filter( 'learndash_user_can_bypass', function( $can_bypass, $user_id, $context, $args ) {

	if ( 'learndash_course_lesson_not_available' === $context ) {
		$course_id = learndash_get_course_id();
		$course_id = absint( $course_id );

		// Change the values to match your course(s).
		if ( ( ! empty( $course_id ) ) && ( in_array( $course_id, array( 6115, 123, 456 ) ) ) ) {

			// Now we check if the user is within a specific Group.

			// Assumed Group_id is 987
			$group_id = 987;

			if ( learndash_is_user_in_group( $user_id, $group_id ) ) {
				$can_bypass = true;
			}

		}
	}

	// Always return $can_bypass.
	return $can_bypass;
}, 30, 4 );