This post was most recently updated on July 31st, 2024
In wordpress you can define different user roles having specific capabilities as per requirement.
Following link gives you the brief idea about various roles and their capabilities.
WordPress user roles and capabilities
You can also create new user role can say custom user role using wordpress function reference.
<?php add_role( $role, $display_name, $capabilities ); ?>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$result = add_role( 'custom_role', __( 'Customizer' ), array( 'read' => true, // true allows this capability 'edit_posts' => true, 'delete_posts' => false, // Use false to explicitly deny ) ); if ( null !== $result ) { echo 'Yay! New role created!'; } else { echo 'Oh... the custom_role role already exists.'; } |
The above example shows the idea of creating new user role in wordpress, in that read, edit_post, delete_post are nothing but the capabilities. In this way, you can add the new user role with different capabilities.