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.


Top ↑

Return Return

(null|WP_Error)


Top ↑

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;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
1.3.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.