Wednesday 23 September 2020

WordPress. Used remove_cap(), getting "Sorry, you are not allowed to access this page." even after removing this function

In WordPress v5.5.1, I have used below function to restrict authors to publish the posts:

function set_capabilities() {
    $author = get_role('author');
    $caps = array(
        'edit_others_posts',
        'edit_others_pages',
        'publish_posts',
        'delete_posts',
        'delete_published_posts',
    );

    foreach ($caps as $cap) {
        $author->remove_cap($cap);
    }
}
add_action('init', 'set_capabilities');

It resulted in complete removal of posts page and adding new posts at wp-admin/post-new.php.

I have removed the set_capabilities() function, still getting the error "Sorry, you are not allowed to access this page.".

I have tried resetting the wp-capabilities, still it did not worked for me.

I have tried adding a new user with author role, the new user have the same issue as well.

How can I have the authors create a post accessing wp-admin/post-new.php again?



from WordPress. Used remove_cap(), getting "Sorry, you are not allowed to access this page." even after removing this function

No comments:

Post a Comment