Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

LLMS_REST_Access_Plans_Controller::related_product_permissions_check( boolean|WP_Error $has_permissions, WP_REST_Request $request )

Check if the current user, who has no permissions to manipulate the access plan post, can edit its related product.


Parameters Parameters

$has_permissions

(boolean|WP_Error) (Required) Whether or not the current user has the permission to manipulate the resource.

$request

(WP_REST_Request) (Required) Full details about the request.


Top ↑

Return Return

(boolean|WP_Error)


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/server/class-llms-rest-access-plans-controller.php

726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
        if ( empty( $request['id'] ) && empty( $request['post_id'] ) ) {
            return $has_permissions;
        }
 
        $product_id = isset( $request['id'] ) /* not creation */ ? $this->get_object( (int) $request['id'] )->get( 'product_id' ) : (int) $request['post_id'];
 
        $product_post_type_object = get_post_type_object( get_post_type( $product_id ) );
 
        if ( current_user_can( $product_post_type_object->cap->edit_post, $product_id ) ) {
            $has_permissions = true;
        }
    }
 
    return $has_permissions;
}
 
/**
 * Allow request when the access plan limit per product is not reached.
 *
 * @since 1.0.0-beta.20


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.20 Made sure either we're creating or updating prior to check related product's permissions.
1.0.0-beta.18 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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