I’m developing a shopping cart plugin, and planning to create a new user role for customers.
My question is how to create custom capabilities so that i can assign these custom capabilities to the new user role, this answer provided a way to create new capabilities, but it is just a new name for the original capabilities.
Can anyone explain how to create a brand new capability which controls some custom functions?
You should first understand that WordPress user roles are simple as set of capabilities. That being said, since you said you are creating a plugin, I like to think you are no stranger to code and hence not afraid to code your solution rather than using another plugin for this.
This code should help you create a new user role and add custom capability to it.
To add a custom capability to this user role use the code below:
Futher reference: https://developer.wordpress.org/plugins/users/roles-and-capabilities/
You can create custom roles and capabilities by plugin. Two options available there by custom code or you can use existing plugin.
For Custom code:
https://wordpress.stackexchange.com/questions/35165/how-do-i-create-a-custom-role-capability
Using existing plugin:
User Roles and Capabilities