WordPress.org

Ready to get started?Download WordPress

Forums

Role Scoper
[resolved] Test if user has access to read a page by ID (2 posts)

  1. danlbob
    Member
    Posted 1 year ago #

    I'm trying to hide certain links to pages in a template based on the current user's role. I've attempted to use...

    global $scoper;
    $users_who_can = $scoper->users_who_can('read', COLS_ALL_RS, 'page', $pageID );

    ...and testing the current user against that list, but that method seems to return all users in all roles. I can verify that the page is correctly restricted by logging in as different users.

    Also I've tried is_restricted_rs($pageID) but that returns 1 no matter what user I'm logged in as. Seems as if that may be an improper use of this function anyway.

    Clearly, this is core functionality but I must be missing something.

    Thanks in advance!

    http://wordpress.org/extend/plugins/role-scoper/

  2. danlbob
    Member
    Posted 1 year ago #

    I did find a solution in the wordpress core functionality.

    $user_can = current_user_can('read', $post_id);
    if($user_can) echo 'Yay, I can read!';

    seems to do the trick.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic