Checking if the current user is able to read private pages fails
-
Hello,
I am using the Members plugin to create user roles with “read_private_pages” access rights. Then I create new pages, set them as private and limit the access to each page to specific user with that specific role only.
However when I want to programmatically check if the current user is able to read (view) that page, it always returns true, even if the user does not have rights to read that page.
I tried following code to list only pages that current user has access to read:
pages = get_pages( array('post_status' => array( 'private' ), )); foreach ( $pages as $page ) { if (current_user_can( 'read_private_pages', $page->ID )) { echo "This user can read page " . $page->post_title; } }
I am not sure why this fails. Any help would be much appreciated.
Thank you!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Checking if the current user is able to read private pages fails’ is closed to new replies.