LLMS_REST_Courses_Controller::update_additional_object_fields( LLMS_Course $course, WP_REST_Request $request, array $schema, array $prepared_item, bool $creating = true )
Updates a single llms course.
Description Description
Parameters Parameters
- $course
-
(Required) LLMS_Course instance.
- $request
-
(Required) Full details about the request.
- $schema
-
(Required) The item schema.
- $prepared_item
-
(Required) Array.
- $creating
-
(Optional) Whether we're in creation or update phase. Default true (create).
Default value: true
Return Return
(bool|WP_Error) True on success or false if nothing to update, WP_Error object if something went wrong during the update.
Source Source
File: libraries/lifterlms-rest/includes/server/class-llms-rest-courses-controller.php
Changelog Changelog
Version | Description |
---|---|
1.0.0-beta.9 | Use WP_Error::$errors in place of WP_Error::has_errors() to support WordPress version prior to 5.1. Also made sure course's instructor is at least set as the post author. |
1.0.0-beta.8 | Call set_bulk() llms post method passing true as second parameter, so to instruct it to return a WP_Error on failure. |
1.0.0-beta.7 | Allow prerequisite and prerequisite_track to be cleared (set to 0). Also: - if prerequisite is not a valid course the course prerequisite will be set to 0; - if prerequisite_track is not a valid course track, the course prerequisite_track will be set to 0. Return false if nothing to update. Properties access_opens_date , access_closes_date , enrollment_opens_date , enrollment_closes_date handling moved here from prepare_item_for_database() method so to better handle the update of the course's properties time_period and enrollment_period . Made access_opens_date , access_closes_date , enrollment_opens_date , enrollment_closes_date properties nullable. Added logic to prevent trying to update "derived only" courses's properties (time_period , enrollment_period , has_prerequisite ) if their values didn't really change, otherwise we'd get a WP_Error which the consumer cannot avoid having no direct control on those properties. |
1.0.0-beta.1 | Introduced. |