LLMS_REST_Posts_Controller::can_access_password_content( LLMS_Post_Model $object, WP_REST_Request $request )
Checks if the user can access password-protected content.
Parameters Parameters
- $object
-
(LLMS_Post_Model) (Required) The LLMS_Post_model object.
- $request
-
(WP_REST_Request) (Required) Request data to check.
Return Return
(bool) True if the user can access password-protected content, otherwise false.
Source Source
File: libraries/lifterlms-rest/includes/abstracts/class-llms-rest-posts-controller.php
public function can_access_password_content( $object, $request ) {
if ( empty( $object->get( 'password' ) ) ) {
// No filter required.
return false;
}
// Edit context always gets access to password-protected posts.
if ( 'edit' === $request['context'] ) {
return true;
}
// No password, no auth.
if ( empty( $request['password'] ) ) {
return false;
}
// Double-check the request password.
return hash_equals( $object->get( 'password' ), $request['password'] );
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 1.0.0-beta.1 | Introduced. |