I have two custom post types for specific posts and I also use the built in post types.

For one of my custom user roles I want to restrict the access to the two CPT only. But I am unable to do this.

I installed the Members plugin to easily manage the capabilities and I denied all access to the post post type which is bulit in to WordPress. The problem is, that the users now also have no access to the CPT, even if they are allowed to access them in the Members plugin.

I don't know why this happens, please help...

Here are the arguments for one of the two CPT. They are both the same (only an other name):

$args = array(
    "label"                   => 'Foo',
    "labels"                  => $labels,
    "public"                  => true,
    "publicly_queryable"      => true,
    "show_ui"                 => true,
    "show_in_rest"            => false,
    "rest_base"               => "",
    "has_archive"             => false,
    "show_in_menu"            => true,
    "exclude_from_search"     => false,
    "capability_type"         => "foo",
    "capabilities"            => array(
                                   'edit_post'          => 'edit_foo',
                                   'read_post'          => 'read_foo',
                                   'delete_post'        => 'delete_foo',
                                   'edit_posts'         => 'edit_foos', 
                                   'edit_others_posts'  => 'edit_others_foos', 
                                   'publish_posts'      => 'publish_foos',       
                                   'read_private_posts' => 'read_private_foos', 
                                   'create_posts'       => 'create_foos'
    "map_meta_cap"            => true,
    "hierarchical"            => true,
    "rewrite"                 => array(
                                   "slug" => "foo",
                                   "with_front" => true
    "query_var"               => true,
    "menu_position"           => 5,
    "supports"                => array(
    "taxonomies"              => array( "foo_tax" ),

The settings in Member are:

Post Type: post

Everything denied, except read because this implies the general access to the WP backend (I have no idea why)

read = true
edit_posts = false
edit_others_posts = false
edit_private_posts = false
edit_published_posts = false
publish_posts = false
read_private_posts = false
delete_posts = false
delete_private_posts = false
delete_published_posts = false
delete_others_posts = false

Post Type: foo

create_foo = false
edit_foos = true
edit_others_foos = true
edit_private_foos = true
edit_published_foos = true
publish_foos = false
read_private_foos = true
delete_foos = false
delete_private_foos = false
delete_published_foos = false
delete_others_foos = false
  • You need to create custom capabilities for your custom post. Here is a great explanation on how to do it. Once you do that you can restrict what role can view, edit, create etc. 3.7designs.co/blog/2014/08/… – Jeff Mattson Oct 4 '16 at 2:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.