Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * General function to check if user can view/read step post.
- *
- * @since 3.4.0
- *
- * @param integer $step_post_id Step Post ID.
- *
- * @return boolean True if user can view/read post.
- */
- protected function can_user_read_step( $step_post_id = 0 ) {
- $user_can_read_post = true;
- if ( ! empty( $step_post_id ) ) {
- if ( is_user_logged_in() ) {
- if ( ! current_user_can( 'read_post', $step_post_id ) ) {
- $user_can_read_post = false;
- }
- } else {
- $step_post = get_post( $step_post_id );
- if ( ( $step_post ) && ( is_a( $step_post, 'WP_Post' ) ) ) {
- if ( ! in_array( $step_post->post_status, array( 'publish' ), true ) ) {
- $user_can_read_post = false;
- }
- }
- }
- }
- /**
- * Filters user can view/read course step.
- *
- * @param boolean $user_can_read_post True if user can read step post.
- * @param integer $step_post_id Step Post ID.
- * @param integer $course_id Course ID.
- */
- return apply_filters( 'learndash_can_user_read_step', $user_can_read_post, $step_post_id, $this->post_id );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement