LLMS_Blocks_Post_Instructors::maybe_set_default_instructor( int $post_id, WP_Post $post, bool $update )
Automatically sets instructor data when a new course/membership is created.
Parameters Parameters
- $post_id
-
(int) (Required) WP_Post ID.
- $post
-
(WP_Post) (Required) Post object.
- $update
-
(bool) (Required) Whether the save is an update (
true
) or a creation (false
).
Return Return
(bool)
Source Source
File: libraries/lifterlms-blocks/includes/class-llms-blocks-post-instructors.php
public function maybe_set_default_instructor( $post_id, $post, $update ) { if ( $update || ! $post->post_author ) { return false; } $obj = llms_get_post( $post ); if ( ! $obj || ! is_a( $obj, 'LLMS_Post_Model' ) || ! in_array( $obj->get( 'type' ), $this->post_types, true ) ) { return false; } remove_action( 'save_post_course', array( $this, 'maybe_set_instructors' ), 50, 3 ); $obj->instructors()->set_instructors( array( array( 'id' => $post->post_author ) ) ); return true; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
1.6.0 | Introduced. |