SlideShare a Scribd company logo
Confidential Customized for Lorem Ipsum LLC Version 1.0
Jonathan Bossenger
Custom Post Types and Capabilities
Learn.WordPress.org
Confidential Customized for Lorem Ipsum LLC Version 1.0
Learn.WordPress.org
What you will learn
1. How to restrict access to custom post types via capabilities?
2. How are capabilities assigned to a custom post type and how to manage them?
3. How to assign custom post type capabilities to existing or new roles?
Confidential Customized for Lorem Ipsum LLC Version 1.0
Learn.WordPress.org
Project requirements - develop a custom
plugin
● Create a custom post type to manage stories.
● Writers can only create, edit, and delete unpublished stories.
● Writers can publish their stories, but not edit or delete stories once published.
● Site administrators can create, edit, and delete any and all stories.
Confidential Customized for Lorem Ipsum LLC Version 1.0
Learn.WordPress.org
Meta Capabilities and Primitive Capabilities
1. Meta capabilities are mapped to primitive capabilities
2. Meta capabilities: edit_post, read_post, delete_post
3. Mapped to primitive capabilities like edit_posts and edit_others posts
4. Meta capabilities are not generally added to roles
Confidential Customized for Lorem Ipsum LLC Version 1.0
Learn.WordPress.org
Meta Capabilities and Primitive Capabilities
1. Two types of primitive capabilities
a. Primitive capabilities that are automatically mapped
b. Primitive capabilities that are NOT automatically mapped
Confidential Customized for Lorem Ipsum LLC Version 1.0
Learn.WordPress.org
The map_meta_cap() function
1. It’s used whenever the current_user_can() function is called.
2. It maps a capability to the primitive capabilities required of the given user to
satisfy the capability being checked, based on the context of the check.
3. It does not check whether the user has the required capabilities, it just returns
what the required capabilities are.
Confidential Customized for Lorem Ipsum LLC Version 1.0
Learn.WordPress.org
Writer role capabilities
1. Automatically mapped primitive capabilities
a. edit_stories, delete_stories, publish_stories, read_private_stories
2. Primitive capabilities mapped inside map_meta_cap:
a. read, delete_private_stories, edit_private_stories,
Confidential Customized for Lorem Ipsum LLC Version 1.0
Learn.WordPress.org
Developing custom post type capabilities
1. Set the correct capability_type(s)
2. Use either the capabilities argument or the map_meta_cap argument
3. Either update an existing role, or create a new custom role, and assign the
relevant capabilities needed
4. Always to set up and remove roles and or capabilities inside activation hook
and deactivation hook callbacks

More Related Content

PPTX
New WordPress Developer APIs The Interactivity API
PPTX
The WordPress HTML API
PPTX
The WordPress Create Block tool
PPTX
PHP compatibility testing with PHPCompatibilityWP
PPTX
Common WordPress APIs_ Settings API
PPTX
Common WordPress APIs - Options API
PPTX
Common WordPress APIs_ HTTP API.pptx
PPTX
Common WordPress APIs: Metadata
New WordPress Developer APIs The Interactivity API
The WordPress HTML API
The WordPress Create Block tool
PHP compatibility testing with PHPCompatibilityWP
Common WordPress APIs_ Settings API
Common WordPress APIs - Options API
Common WordPress APIs_ HTTP API.pptx
Common WordPress APIs: Metadata

More from Jonathan Bossenger (20)

PPTX
What’s new for developers_ (August 2023).pptx
PPTX
Testing your plugins for PHP version compatibility
PPTX
Common WordPress APIs_ Global Variables
PPTX
Common WordPress APIs_ Internationalization
PPTX
Testing WordPress 6.3 - Developer edition
PPTX
Common WordPress APIs: Responsive Images
PPTX
Common WordPress APIs - Dashboard Widgets
PPTX
Custom Tables in WordPress
PPTX
The WordPress Database
PPTX
WordPress Coding Standards
PPTX
Managing a WordPress Multisite Network
PPTX
Debugging in WordPress
PPTX
Testing plugins for PHP 8
PPTX
Introduction to WordPress Multisite Networks
PPTX
Developing for multisite
PPTX
Developing WordPress User Roles and Capabilities
PPTX
Let's code: WordPress multisite experiments
PPTX
Creating a WordPress multisite network
PPTX
Extending WordPress: common security vulnerabilities
PPTX
WP REST API - custom routes and endpoints
What’s new for developers_ (August 2023).pptx
Testing your plugins for PHP version compatibility
Common WordPress APIs_ Global Variables
Common WordPress APIs_ Internationalization
Testing WordPress 6.3 - Developer edition
Common WordPress APIs: Responsive Images
Common WordPress APIs - Dashboard Widgets
Custom Tables in WordPress
The WordPress Database
WordPress Coding Standards
Managing a WordPress Multisite Network
Debugging in WordPress
Testing plugins for PHP 8
Introduction to WordPress Multisite Networks
Developing for multisite
Developing WordPress User Roles and Capabilities
Let's code: WordPress multisite experiments
Creating a WordPress multisite network
Extending WordPress: common security vulnerabilities
WP REST API - custom routes and endpoints
Ad

Recently uploaded (20)

PPTX
Spectroscopy.pptx food analysis technology
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Machine Learning_overview_presentation.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Electronic commerce courselecture one. Pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Spectroscopy.pptx food analysis technology
Network Security Unit 5.pdf for BCA BBA.
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Spectral efficient network and resource selection model in 5G networks
Per capita expenditure prediction using model stacking based on satellite ima...
Dropbox Q2 2025 Financial Results & Investor Presentation
Unlocking AI with Model Context Protocol (MCP)
Review of recent advances in non-invasive hemoglobin estimation
MIND Revenue Release Quarter 2 2025 Press Release
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Machine Learning_overview_presentation.pptx
A Presentation on Artificial Intelligence
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
sap open course for s4hana steps from ECC to s4
Electronic commerce courselecture one. Pdf
20250228 LYD VKU AI Blended-Learning.pptx
Machine learning based COVID-19 study performance prediction
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Chapter 3 Spatial Domain Image Processing.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Ad

Custom Post Types and Capabilities.pptx

  • 1. Confidential Customized for Lorem Ipsum LLC Version 1.0 Jonathan Bossenger Custom Post Types and Capabilities Learn.WordPress.org
  • 2. Confidential Customized for Lorem Ipsum LLC Version 1.0 Learn.WordPress.org What you will learn 1. How to restrict access to custom post types via capabilities? 2. How are capabilities assigned to a custom post type and how to manage them? 3. How to assign custom post type capabilities to existing or new roles?
  • 3. Confidential Customized for Lorem Ipsum LLC Version 1.0 Learn.WordPress.org Project requirements - develop a custom plugin ● Create a custom post type to manage stories. ● Writers can only create, edit, and delete unpublished stories. ● Writers can publish their stories, but not edit or delete stories once published. ● Site administrators can create, edit, and delete any and all stories.
  • 4. Confidential Customized for Lorem Ipsum LLC Version 1.0 Learn.WordPress.org Meta Capabilities and Primitive Capabilities 1. Meta capabilities are mapped to primitive capabilities 2. Meta capabilities: edit_post, read_post, delete_post 3. Mapped to primitive capabilities like edit_posts and edit_others posts 4. Meta capabilities are not generally added to roles
  • 5. Confidential Customized for Lorem Ipsum LLC Version 1.0 Learn.WordPress.org Meta Capabilities and Primitive Capabilities 1. Two types of primitive capabilities a. Primitive capabilities that are automatically mapped b. Primitive capabilities that are NOT automatically mapped
  • 6. Confidential Customized for Lorem Ipsum LLC Version 1.0 Learn.WordPress.org The map_meta_cap() function 1. It’s used whenever the current_user_can() function is called. 2. It maps a capability to the primitive capabilities required of the given user to satisfy the capability being checked, based on the context of the check. 3. It does not check whether the user has the required capabilities, it just returns what the required capabilities are.
  • 7. Confidential Customized for Lorem Ipsum LLC Version 1.0 Learn.WordPress.org Writer role capabilities 1. Automatically mapped primitive capabilities a. edit_stories, delete_stories, publish_stories, read_private_stories 2. Primitive capabilities mapped inside map_meta_cap: a. read, delete_private_stories, edit_private_stories,
  • 8. Confidential Customized for Lorem Ipsum LLC Version 1.0 Learn.WordPress.org Developing custom post type capabilities 1. Set the correct capability_type(s) 2. Use either the capabilities argument or the map_meta_cap argument 3. Either update an existing role, or create a new custom role, and assign the relevant capabilities needed 4. Always to set up and remove roles and or capabilities inside activation hook and deactivation hook callbacks

Editor's Notes

  • #2: TITLE SLIDE: Make a copy of this presentation to your Google Drive, and edit to replace with your details.
  • #3: TITLE SLIDE: Make a copy of this presentation to your Google Drive, and edit to replace with your details.
  • #4: TITLE SLIDE: Make a copy of this presentation to your Google Drive, and edit to replace with your details.
  • #5: TITLE SLIDE: Make a copy of this presentation to your Google Drive, and edit to replace with your details.
  • #6: TITLE SLIDE: Make a copy of this presentation to your Google Drive, and edit to replace with your details.
  • #7: TITLE SLIDE: Make a copy of this presentation to your Google Drive, and edit to replace with your details.
  • #8: TITLE SLIDE: Make a copy of this presentation to your Google Drive, and edit to replace with your details.
  • #9: TITLE SLIDE: Make a copy of this presentation to your Google Drive, and edit to replace with your details.