LLMS_Blocks_Post_Visibility::update_callback( string $value, WP_Post $object, string $key )
Update visibility information for a given object.
Parameters Parameters
- $value
-
(string) (Required) new visibility status value.
- $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-visibility.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 visibility.', 'lifterlms' ),
array(
'key' => $name,
'status' => rest_authorization_required_code(),
)
);
}
$obj = new LLMS_Product( $object->ID );
if ( $obj ) {
$obj->set_catalog_visibility( $value );
}
return null;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 1.3.0 | Introduced. |