I have created a new user role - vendor - with the capability to read_private_pages, but when I log in as such a user, and go to a private page I cannot see it.

Here is my plugin code:

function fc_add_role($role, $display_name, $capabilities = array()) {
    if (!empty($role)) {
        return wp_roles()->add_role( $role, $display_name, $capabilities );
if (!get_role('vendor')){
    fc_add_role('vendor', 'Vendor', array('read_private_pages', 'read_private_posts'));

And when I go to my private page as a vendor, it just shows:

Oops! That page can’t be found.

It looks like nothing was found at this location. Maybe try one of the links below or a search?

What am I doing wrong? And how can I make it so vendor users can read private pages?

NB - When I log in as admin, I can see the private page.

1 Answer 1


Your capabilities should be a key value pair:

fc_add_role('vendor', 'Vendor', array(
        'read_private_pages' => true, 
        'read_private_posts' => true

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.