Understanding user capabilities

Capabilities can be considered as tasks that users are permitted to perform inside the application. A single user role can perform many capabilities, while a single capability can be performed by many user roles. Typically, we use the term access control for handling capabilities in web applications. Let's see how capabilities work inside WordPress.

Creating your first capability

Capabilities are always associated with user roles, and hence we cannot create new capabilities without providing a user role. Let's look at the following code for associating a custom capability with a follower user role created in the Creating user roles for a application section:

public function add_application_user_capabilities(){ $role ...

Get WordPress Web Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.