learndash_lesson_is_sample

apply_filters( 'learndash_lesson_is_sample',  boolean $is_sample,  WP_Post|array|null $post )

Filters whether the lesson is a sample lesson or not.


Description #


Parameters #

$is_sample

(boolean) Whether the lesson is a sample lesson or not.

$post

(WP_Post|array|null) Post Object.


Source #

File: includes/ld-misc-functions.php


Examples #

 <?php
/**
 * Example usage for learndash_lesson_is_sample filter.
 */
add_filter(
	'learndash_lesson_is_sample',
	function( $is_sample, $post ) {
		if ( true === $is_sample ) {
			// Example 1: We want to only allow logged in users to access samples.
			if ( ! is_user_logged_in() ) {
				$is_sample = false;
			}
		}

		// Always return $is_sample;
		return $is_sample;
	},
	30,
	2
);