LLMS_REST_Posts_Controller::check_read_permission( LLMS_Post_Model $object )

Checks if an llms post can be read.


Parameters Parameters

$object

(LLMS_Post_Model) (Required) The LLMS_Post_model object.


Top ↑

Return Return

(bool) Whether the post can be read.


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/abstracts/class-llms-rest-posts-controller.php

	 *
	 * @since 1.0.0-beta.1
	 *
	 * @param LLMS_Post_Model $object The LLMS_Post_model object.
	 * @return bool Whether the post can be deleted.
	 */
	protected function check_delete_permission( $object ) {

		$post_type = get_post_type_object( $this->post_type );
		return current_user_can( $post_type->cap->delete_post, $object->get( 'id' ) );

	}

	/**
	 * Checks if an llms post can be read.
	 *
	 * @since 1.0.0-beta.1
	 * @since [version] Fix fatals when searching for llms post type based resources
	 *                  but the query post type parameter is forced to be something else.
	 *
	 * @param LLMS_Post_Model $object The LLMS_Post_model object.
	 * @return bool Whether the post can be read.
	 */
	protected function check_read_permission( $object ) {

		if ( is_wp_error( $object ) ) {
			return false;
		}

		$post_type = get_post_type_object( $this->post_type );
		$status    = $object->get( 'status' );
		$id        = $object->get( 'id' );
		$wp_post   = $object->get( 'post' );

		// Is the post readable?
		if ( 'publish' === $status || current_user_can( $post_type->cap->read_post, $id ) ) {


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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