0

My goal: A custom post type with a complete custom editor page and post list table.

I have set show_ui to false. It removed the UI section. But if some admin puts direct link (wp-admin/edit.php?post_type=custom_post) in the browser, it takes them to the post table page, and clicking from there takes to editor page. How can I stop this? I don't want anyone to get access to this two pages. I have made two custom pages for them.

Or is there any other better way?

0

Yes. Use capabilities! When registering a post type, take a look at the capability_type and capabilities.

You can define a custom capability map for the standard edit_post, delete_post, etc. for your post type.

The thing you remember is, if you customize the capabilities, YOU DON'T HAVE THESE CAPABILITIES EITHER! This means you'll have to get those capabilities on your user role. (probably Administrator?)

You need to then either create a new user role and assign capabilities to it, or just use a plugin like Members which gives you a good interface to create these and assign capabilities to existing roles, as well as creating new roles altogether.

  • Thanks for the head Eric. If I set custom capability type, then it meets my goal somehow, as it won't allow anyone without the "new capability" permission to access those pages, not even administrator. And I actually don't need to provide that permission to anyone. But there comes a new question: from the custom editor page, will be an admin without "new capability" permission able to submit posts? I will be using wp_insert_post. – тнє Sufi Oct 6 '15 at 17:23
  • I'd have to say.. test it? In wp_insert_post there is a capability check for setting the status to publish, but I don't see any others in the source code. – Eric Holmes Oct 6 '15 at 17:27
  • Thanks again. It will be quiet tough to test it at this moment, as the plugin is in the planning phase. However, I will write a simple code block to test this particular problem. Will update by tomorrow. – тнє Sufi Oct 6 '15 at 17:41

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.