learndash_previous_step_completed

apply_filters( 'learndash_previous_step_completed',  bool $previous_step_completed,  int $step_id,  int $user_id )

Filter to override previous step completed.


Description #


Parameters #

$previous_step_completed

(bool) True if previous step completed.

$step_id

(int) Step Post ID.

$user_id

(int) User ID.


Source #

File: includes/class-ld-cpt-instance.php


Examples #

 <?php
/**
 * Example usage for learndash_previous_step_completed filter.
 */
add_filter(
	'learndash_previous_step_completed',
	function( $display_content = false, $post_id = 0, $user_id = 0 ) {

		// Example 1) Check if user is admin or group_leader
		// if ( ( user_can( $user_id, 'administrator' ) ) || ( user_can( $user_id, 'group_leader' ) ) ) {
		// $display_content = true;
		//
		// Remove this filter to also let the user get past drip feed limilations
		// remove_filter( 'learndash_content', 'lesson_visible_after', 1, 2 );
		// }

		// Example 2) Check post type
		// $post_type = get_post_type( $post_id );
		// if ( $post_type == 'sfwd-lessons')
		// $display_content = true;

		return $display_content;
	},
	10,
	3
);