Assign Custom Capability
Overview
Assign a full custom post type capability set to the Administrator role.
Replace <cap_singular> and <cap_plural> with the capability bases for the CPT before using the snippet. For example, a book CPT that uses a plural capability base of books would use capabilities such as edit_book, read_book, edit_books, and publish_books.
Run this only after the role and capability names are final. The snippet grants capabilities on init; it does not remove capabilities if the placeholders are changed later.
Variants
- Procedural
- OOP