LLMS_Instructor::is_instructor( int $post_id = null )
Determine if the user is an instructor on a post
Parameters Parameters
- $post_id
-
(int) (Optional) WP Post ID of a course or membership
Default value: null
Return Return
(boolean)
Source Source
File: includes/models/model.llms.instructor.php
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | public function is_instructor( $post_id = null ) { $ret = false; // Use current post if no post is set. if ( ! $post_id ) { global $post ; if ( ! $post ) { return apply_filters( 'llms_instructor_is_instructor' , $ret , $post_id , $this ); } $post_id = $post ->ID; } $check_id = false; switch ( get_post_type( $post_id ) ) { case 'course' : $check_id = $post_id ; break ; case 'llms_membership' : $check_id = $post_id ; break ; case 'llms_question' : $question = llms_get_post( $post_id ); $check_id = array (); foreach ( $question ->get_quizzes() as $qid ) { $course = llms_get_post_parent_course( $qid ); if ( $course ) { $check_id [] = $course ->get( 'id' ); } } break ; default : $course = llms_get_post_parent_course( $post_id ); if ( $course ) { $check_id = $course ->get( 'id' ); } } if ( $check_id ) { $check_ids = ! is_array ( $check_id ) ? array ( $check_id ) : $check_id ; $query = $this ->get_posts( array ( 'post__in' => $check_ids , 'posts_per_page' => 1, ), 'query' ); $ret = $query ->have_posts(); } return apply_filters( 'llms_instructor_is_instructor' , $ret , $post_id , $check_id , $this ); } |
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.13.0 | Introduced. |