Create custom permissions for user type

I’m currently wanting to have it so that writers on my site have to have an admin approve their content before it’s published, but still be allowed to do other tasks such as uploading images, adding tags, etc, and the wordpress static permission levels are either too restrictive, or let writers publish themselves.

I know on drupal there is an easy way to edit permissions for account types, but I was wondering if there is a way to do the same level of functionality with wordpress at all.

Related posts

Leave a Reply

2 comments

  1. Plugins that would do this are:

    Or you can write it into your theme’s functions.php

    Personally, I prefer to write it into functions.php rather than install a plugin. It’s more secure and typically keeps your site running faster.

  2. First, choose one wordpress role your writer’ll have : author, contributor, editor… or a custom role.

    then customize your chosen role with capacities in your functions.php theme file :

    if ( ! function_exists( 'writer_set_roles' ) ):
     function writer_set_roles()
     {
        global $wp_roles;
    
        // post / page editing
        $wp_roles->add_cap('author','edit_others_pages');
        $wp_roles->add_cap('author','edit_published_pages');
        $wp_roles->add_cap('author','edit_private_pages');
        $wp_roles->add_cap('author','publish_pages');
        $wp_roles->add_cap('author','delete_pages');
        $wp_roles->add_cap('author','delete_others_pages');
        $wp_roles->add_cap('author','delete_others_posts');
        $wp_roles->add_cap('author','delete_published_pages');
        $wp_roles->add_cap('author','manage_categories');
    
        // appearance
        $wp_roles->add_cap('author','edit_themes');
        $wp_roles->add_cap('author','edit_theme_options');
        $wp_roles->add_cap('author','manage_widgets');
        $wp_roles->add_cap('author','edit_widgets');
    
        // sample for plugin caps
        $wp_roles->add_cap('author','NextGEN Gallery overview');
        $wp_roles->add_cap('author','NextGEN Use TinyMCE');
        $wp_roles->add_cap('author','NextGEN Upload images');
        $wp_roles->add_cap('author','NextGEN Manage gallery');
        $wp_roles->add_cap('author','NextGEN Manage others gallery');
      }
    endif;
    
    add_action( 'after_setup_theme', 'writer_set_roles' );
    

    you should find all capacities in this file :
    https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/schema.php

    or in documentation.
    https://codex.wordpress.org/Roles_and_Capabilities