Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * If query filtering is enabled, hide course steps from the course
- * navigation.
- *
- * @since 3.36.16
- *
- * @param bool $can_read Can the user read the step?
- * @param int $step_id The step ID.
- * @param int $course_id The course ID.
- * @return bool True if able to user read step, False otherwise.
- */
- public function can_user_read_step( $can_read, $step_id, $course_id ) {
- if ( ! $can_read ) {
- return $can_read;
- }
- if ( $can_read ) {
- // If Filter Course Steps is on
- $settings = get_post_meta( $course_id, 'wpf-settings-learndash', true );
- if ( ! empty( $settings ) && ! empty( $settings['filter_steps'] ) ) {
- if ( ! wpf_user_can_access( $step_id ) ) {
- $can_read = false;
- }
- }
- }
- if ( false === $can_read ) {
- // Reduce the course step count
- add_filter( 'learndash-course-progress-stats', function( $progress ) {
- $progress['total'] -= 1;
- return $progress;
- } );
- }
- return $can_read;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement