LLMS_Blocks_Post_Instructors::update_callback( string $value, WP_Post $object, string $key )
Update instructor information for a given object.
Parameters Parameters
- $value
-
(string) (Required) Instructor data to add to the object (JSON).
- $object
-
(WP_Post) (Required) WP_Post object.
- $key
-
(string) (Required) Name of the field.
Return Return
(null|WP_Error)
Source Source
File: libraries/lifterlms-blocks/includes/class-llms-blocks-post-instructors.php
public function update_callback( $value, $object, $key ) { if ( ! current_user_can( 'edit_post', $object->ID ) ) { return new WP_Error( 'rest_cannot_update', __( 'Sorry, you are not allowed to edit the object instructors.', 'lifterlms' ), array( 'key' => $key, 'status' => rest_authorization_required_code(), ) ); } $value = json_decode( $value, true ); $obj = llms_get_post( $object ); if ( $obj ) { $obj->instructors()->set_instructors( $value ); } return null; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
2.4.0 | Fix access to non-existing variable when current user canno edit the course/membership. |
1.7.1 | Decode JSON prior to saving. |
1.0.0 | Introduced. |