• Resolved gl03

    (@gl03)


    I’m looking to create a custom user role that is (only) granted permission to create/edit/delete a Custom Post Type (CPT), programmatically added in my theme’s function.php.

    Now I would assume to find the permissions associated with my CPT under ‘Members > Add New Role > {My-CPT-Name}‘, analogous to Posts, Pages, Media etc. It is however not listed among the tabs on the left-hand side.

    What am I be missing here? Perhaps some required option in register_post_type(), or am I simply looking in the wrong place / for the wrong thing?

    Otherwise my CPT works as it’s supposed to within WP admin, and can be queried by my React app via WPGraphQL without issues.

    Thank you!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Caseproof

    (@caseproof)

    Hi @gl03

    All capabilities registered in CPT should be visible under All tab when you edit role in Members > Roles. You can also review “Registering Capabilities” and “Registering Cap Groups” sections in our doc: https://members-plugin.com/docs/snippets/ to see how to see custom capabilities in a nicely-formatted way.

    I hope that helps.

    Thread Starter gl03

    (@gl03)

    Thank you for getting back. Unfortunately I don’t see any capabilities associated with my CPT under the ‘All’ tab when editing my custom role.

    Please forgive the newbie question, but do I have to manually declare standard capabilities like create, edit, delete when I register my CPT? I was under the impression that such caps are automatically inherited from the Post post type.

    My CPT definition looks something like this:

    register_post_type('spot',
    array(
    'labels' => array(
    [...]
    ),
    'supports' => array('title', 'thumbnail', 'revisions'),
    'public' => true,
    'has_archive' => true,
    'show_in_rest' => true,
    'rest_base' => 'spots',
    'show_in_graphql' => true,
    'graphql_single_name' => 'spot',
    'graphql_plural_name' => 'spots',
    'publicly_queryable' => true, 
    )
    );
    }

    Accordingly I would simply expect to find ‘create_spot‘, edit_spot‘, ‘delete_spot‘ and so on to be selectable under my custom role capabilities.

    What am I missing? Many thanks!

    I am actually having an identical issue. I do not see my custom post type appearing on the left-hand sidebar when editing a role. Additionally, I thought that the CPT inherited from Post by default and would map for me. As an example, I thought that my Careers custom post type would automatically get the edit_careers (from edit_posts) capability and then I could tell the Members plugin to GRANT the edit_careers capability while restricting the role to a editing careers CPT but not regular posts or other CPTs. Am I missing something here?

    Thank you!

    I solved my issue, so hopefully it helps you out as well. I added the following code to my custom post type’s $args array.

    ‘capability_type’ => array(‘career’, ‘careers’),

    ‘map_meta_cap’ => true

    This made the CPT appear in the sidebar and the inherited capabilities from the Post post type also appeared (with their proper CPT names). I tested it out and granted/denied permission as needed for the role, and it worked!

    I hope that fixes it for you as well!

    Thread Starter gl03

    (@gl03)

    Thank you Isaac, I found out the same thing and was going to return here and post it.

    Would make a nice addition to the docs tbh.

    Would you need to add this to a custom taxonomy that’s on a cpt as well? The user role can see/edit the cpt but cannot see the custom taxonomy associated with that cpt.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Can’t see Custom Post Type permissions’ is closed to new replies.