# WordPress – Create a custom user role

Sometimes you want to create a special user with a special name and behavior inside WordPress
The way to add a custom user role is the following:

function add_capability() {
    // Add a custom user role (1) - Let’s say… God!
    $result = add_role( 'god', __(‘God'),
    'read' => true, // true allows this capability (because it’s god).
    'edit_posts' => true, // Allows user to edit their own posts
    'edit_pages' => true, // Allows user to edit pages
    'edit_others_posts' => true, // Allows user to edit others posts not just their own
    'create_posts' => true, // Allows user to create new posts
    'manage_categories' => true, // Allows user to manage post categories
    'publish_posts' => true, // Allows the user to publish, otherwise posts stays in draft mode
    'edit_themes' => false, // false denies this capability. User can’t edit your theme (god or no god, no on is touching my theme)
    'install_plugins' => false, // User cant add new plugins
    'update_plugin' => false, // User can’t update any plugins
    'update_core' => false // user cant perform core updates
    // Add a custom user role (2) - member
    $result2 = add_role( 'member', __('Member' ),
   'read' => true, 
   'edit_posts' => true,
   'edit_pages' => true, 
   'edit_others_posts' => true, 
   'create_posts' => true,
   'manage_categories' => true, 
   'publish_posts' => true,
    'edit_themes' => false,
    'install_plugins' => false,
    'update_plugin' => false, 
   'update_core' => false

add_action( 'admin_init', ‘add_capability');

# WordPress – Delete a user role

You can also remove roles,
To delete a user role, you should add in your function.php :

remove_role( 'member' ); 

Note: Be carful cant be undone, also the users with this role will be with no privileges on the website,
this will totally delete the role. and if you need to get it back, you need to add it all over again and set this role privileges all over again.