WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Types And User Roles (5 posts)

  1. Jaap
    Member
    Posted 3 years ago #

    Hi,

    I create custom post types in the plugin called 'More Fields'.

    I have 5 different post types created.
    Like: Products, Cats, Dogs, Jobs, Pinguins.

    I have 2 user roles.
    Userrole 1 can post Products, Cats and Dogs.

    The other user role can post Jobs and Pinguins.

    When you post a new pinguin you see this in your URL

    /post-new.php?type=Pinguins

    When I am userrole 1 and I replace Pinguins to Products (Which only user role 2 should be able to post) I can post these posts too?

    So theres no restriction on that. Only the UI gets removed but not the access to it if you change your URL.

    How can this be fixed?

    Thanks in advance.

  2. Mark / t31os
    Moderator
    Posted 3 years ago #

    Depends how the capabilities are setup, default behvaiour for a post type is to inherit capabilities from the post post_type.

    See the capabilities parameter on the register_post_type page.

  3. Jaap
    Member
    Posted 3 years ago #

    Well yeah both user roles must be able to post Posts but not the posts That i dissalow in the plugin more fields. Now it only disables the menu but u can still acces other post types through the url bar. Hope that can be fixed would be real helpfull.

  4. Mark / t31os
    Moderator
    Posted 3 years ago #

    I think you might be missing the point i was making before, if you don't give your custom post type custom capabilities, the post type uses the same capabilities as a regular post. Therefore, if a user can edit "posts", they can also edit your custom post type (because the capability requirement is exactly the same).

    Does that help to clarify?

  5. alanchrishughes
    Member
    Posted 2 years ago #

    Are there any basic examples of how to write this? I'm also trying to create specific user roles for specific post types.

Topic Closed

This topic has been closed to new replies.

About this Topic