Sometimes we need to add custom user roles in our WordPress CMS. The following code snippets will add a custom user role inside your CMS. For more roles, please see the capabilities from Codex or WordPress documentary. This is just an example to start it right away.

// To add the new role, using 'customeditor' as the short name and
// 'Custom Editor' as the displayed name in the User list and edit page:
 
add_role('customeditor', 'Custom Editor', array(
    'read' => true, // True allows that capability, False specifically removes it.
    'edit_posts' => true,
    'delete_posts' => true,
    'edit_published_posts' => true,
    'publish_posts' => true,
    'edit_files' => true,
    'import' => true,
    'upload_files' => true //last in array needs no comma!
));
 
  
// To remove one outright or remove one of the defaults:
/*
remove_role('customeditor');
*/