I am working with the Role and Capabilities API for the first time today and making use of the the excellent Members plugin. Having tinkered around for some time I notice that the “edit pages” capability does two things:
- Allow the user to create a new page
- Allow the user to edit existing pages
I am trying to split this capability into two. I want my user to:
- Not be able to create any new pages
- Allow the user to edit existing pages
I am looking to write some code for my theme that allows this to happen. I can create a new capability very easily. The challenge is then getting WordPress to respond accordingly to it.
Any thoughts would be appreciated.
Yes, this is indeed a problem. A dedicated ‘create_posts’ capability is planed:
http://core.trac.wordpress.org/ticket/16714
Hi I have been researching this for a while, came up with the following hack.
In wp-admin/new_post.php add the following, after the wp_die line:
then in wp-admin/menu, add a conditional for showing the add page submenu in admin. The line is normally there but not included within the if statement
I still have to figure out how to remove the add new button in the edit pages, however users with publish rights can now edit existing pages but not create new pages. If they press the new page button they get a warning and cannot proceed further. Posts are not affected. The same code could easily be applied to prevent the creation of new posts aswell with just little editing.
Hope this helps – Ackab