• Resolved rajaito

    (@rajaito)


    I need to limit users to be able to only post one CPT. I got some advice from a
    developer on how to do this and apparently CPT UI is missing the ability to set custom capabilities. Seems like a good feature request, so I am posting it here.

    I’m looking through the CPT UI plugin code. It doesn’t set the capabilities under the hood. It only sets the capability_type.

    The reason this is not good is because if there’s no create_posts cap set, then it’ll automatically fallback to whatever your edit_posts cap is.

    At this point, I can’t think of any other way around this. You need the create_posts cap set to be able to target post creation. This means you need to code the CPT registration on your own or ask the CPT UI plugin author to update their plugin to allow you to add in custom capabilities.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I fully admit to the capabilities topic not being fully fleshed out, and having some large holes. Probably the area most lacking overall. However, that doesn’t mean you’re out of luck.

    I would look at this spot right here: https://github.com/WebDevStudios/custom-post-type-ui/blob/master/custom-post-type-ui.php#L441-L451

    With this filter, you’re passed the determined arguments to be used for a given post type, in the form of an array. You’re also passed the current post type slug being registered, as well as the original values plucked from the CPTUI settings in case you need the “pre” version.

    The array you’re given will be a matching structure as what you’d pass in to register_post_type if you were setting it up yourself. With that, you could inject the capabilities index and set them to whatever you need.

    I know I would like to get some UI built out for the topic, but I also want to make sure I have a solid understanding of the nuances with capabilities and what all may or may not be required to properly configure. That way we can properly implement while hopefully preventing users from accidentally “breaking” things.

    Hello can you tell me is there possibility to create Parent post type? for example:

    Movies will be the Parent post type : and Drama ,Fantasy etc… will be child post type

    i dont want to create posts in Parent post types,only in child

    When the user passes by the link (like: mysite.com/movies ) so that he or she sees all the posts.thank you

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Hey @karencho777,

    Just for clarification, in case there’s some confusion, the idea of post types can’t have parent/child relationships. What CAN have that relationship is posts IN the post type.

    That said, if you’re wanting a setup where someone goes to mysite.com/movies/ and sees all of the movie posts, then I’d recommend simply using “movies” as the post type slug when registering a post type, and making sure to set the option for it to have an archive.

    Marking resolved, regarding the original thread topic at hand.

    i want to have Movies as parent but other categories must be because movies must be under categories… i need to go mysite.com/movies and there was whole database but also rwant to have mysite.com/movies/drama or mysite.com/movies/fantasy

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    It sounds like you’re wanting “movies” to be a taxonomy, more than a post type. Either that, or “movies” needs to be a post inside a post type. Note that taxonomies don’t get archives out of the box quite the same way that post types do. I wrote a post about a workaround of sorts for that topic over at https://pluginize.com/how-to-create-a-taxonomy-archive-in-wordpress/

    That said, this should honestly be its own support thread rather than tacking on to the original poster’s thread.

    Can you tell me one thing more,can post be in several custom types and if not,if i will copy it manually that will not like search engines yes?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Each post would have its own row in the wp_posts table, so you wouldn’t have a spot where you could edit once and have it reflect across multiple. I imagine you could code up something like that, but it would definitely be a custom solution.

    Regarding the SEO part, I guess I fail to see why they would favor the multiple post types version and not favor the manually copied version. Both would reference the same content in multiple places.

    so you are saying that with Seo will be no problem yes?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I can’t say for certain, as I am not an SEO person to the degree that I can make recommendations with confidence. I’m just saying that both examples seem to imply matching content seen at multiple URLs, to my mind.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Custom capabilities’ is closed to new replies.