I wonder if it is possible to create a new user role and give him special limited abilities?

I’d like to have some users who can only add events onto the calendar. They should only be able to work within events calendar taxonomy and edit add their posts but not publish them something like contributor but more limited!

4 s
4

Yes. WordPress has robust built-in Roles and Capabilities system desgined to do exactly what you are looking for.

To add a new role, use the add_role() function in your theme’s functions.php or a plug-in like so:

$role = add_role( 'event_manager', 'Event Manager', array(
    'read' => true, // True allows that capability
) );

if ( null !== $role ) {
    echo 'Yay!  New role created!';
} else {
    echo 'Oh... the event_manager role already exists.';

}

To add a new capability, use the add_cap() function like this:

$role = get_role( 'event_manager' );
$role->add_cap( 'manage_events' );

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *