Can't add new capabilities with a - in the name #80
Comments
Capabilities really shouldn't have hyphens in them. Is there a particular plugin that you're using that's creating this capability? Maybe we can get in touch with the author to have them switch to an underscore. |
I can't change the hyphen in the name, because the custom post type i have registered contain the hyphen in the name. And i have numerous posts with this custom post type, so if i change the name i lose every post created with this particular custom post type... |
The name of your post type is irrelevant. If you're registering a post type, you have complete control over the names of the capabilities. Example: https://gist.github.com/justintadlock/6552000#file-register-post-type-php-L93 As a sidenote: it's non-standard to hyphenate post type names as well. It creates weird hook names sometimes with both hyphens and underscores. |
Hi, What do you sugguest when you have a complex custom post type name? (about syntax). But could you explain to me the diff between a primary cap and a map_meta_cap ? |
This isn't really the place for me to teach how to build CPTs, so I'm going to keep this short and simple. In general, the naming scheme should follow these rules:
As for caps, you should be setting the entire You can name your capabilities anything. That's up to you. They don't have to match your post type name at all (usually, they should be similar though just for organizational purposes). If you want an example of a real-world plugin, here's one I built: https://github.com/justintadlock/custom-content-portfolio/blob/master/inc/functions-post-types.php |
ok thanks. Yes we know that's not the good place but the background aim is why with your plugin it's forbidden. Understood now. The last question is the difference in caps between a cap with and without ending "s". |
I try to add a new custom capability from the wordpress admin.
This capability is linked to a custom post type named page-arrivee.
The isssue is :
When i try to add the capability read_page-arrivee to a specific user role, it adds in fact the capability read_pagearrivee removing the "-".
Is it possible to avoid this ?
Thank you.
The text was updated successfully, but these errors were encountered: