learndash_lesson_sample_access

apply_filters( 'learndash_lesson_sample_access',  boolean $access,  integer $post_id,  integer $user_id )

Filters whether to allow access to the sample lesson or not.


Description #

By default a sample lesson is available even to anonymous users. This filter will override that access. The filer ‘learndash_can_access_sample’ is also used themes/ld30/templates/lesson/partials/row.php to control visibility of the lesson and sub-steps.


Parameters #

$access

(boolean) Access status true if the user can access $post_id.

$post_id

(integer) Course step the user is trying to access.

$user_id

(integer) User ID.


Source #

File: themes/ld30/includes/helpers.php


Examples #

 <?php
/**
 * Example usage for learndash_lesson_sample_access filter.
 */
add_filter(
	'learndash_lesson_sample_access',
	function( $access, $post_id, $user_id ) {
		// May add any custom logic using $access, $post_id, $user_id.

		// Always return $access.
		return $access;
	},
	10,
	3
);
 

Changelog #

Changelog
Version Description
3.2.0 Introduced.