Codex tools: Log in
Contents |
Adds a new role to WordPress.
NB: This setting is saved to the database (in table wp_options, field wp_user_roles), so it might be better to run this on theme/plugin activation
<?php add_role( $role, $display_name, $capabilities ); ?>
$result = add_role('basic_contributor', 'Basic Contributor', array(
'read' => true, // True allows that capability
'edit_posts' => true,
'delete_posts' => false, // Use false to explicitly deny
));
if (null !== $result) {
echo 'Yay! New role created!';
} else {
echo 'Oh... the basic_contributor role already exists.';
}
add_role() is located in wp-includes/capabilities.php.
Roles and Capabilities: add_role(), remove_role(), get_role(), add_cap(), remove_cap()