apply_filters( 'learndash_lesson_sample_access', bool $access, int $lesson_id, int $post_id, int $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
-
(bool) Access status true if the user can access $post_id.
- $lesson_id
-
(int) Lesson ID.
- $post_id
-
(int) Course step the user is trying to access.
- $user_id
-
(int) User ID.
Source #
Examples #
Note: Extended code example below not guaranteed, you may need to consult with a developer
<?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 #
| Version | Description |
|---|---|
| 3.2.0 | Introduced. |