如何在wordpress上添加自定义角色功能?

pardon me,i want make official website. and that are most important role :

  • first (author) , user can post their content (i know wordpress already have that feature). author can not publish content in public.

  • second (validator, i thank that name), user can see content from the first role (author) and add comment. if content good enough that content can pass to third role.

  • third. (publish), user only can see content from first role. add publish it

how i add cutom function role on wordpress?

ps: sorry for my bad english.

you can create and change capability to custom usser role via plugin https://wordpress.org/plugins/user-role-editor/

if you have advance knowledge of wordpress, you can create custom user role and set capability for specific user role.

$result = add_role(
'basic_contributor',
__( 'Basic Contributor' ),
array(
    'read'         => true,  // true allows this 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.';
}

https://codex.wordpress.org/Function_Reference/add_role

https://codex.wordpress.org/Roles_and_Capabilities

if you are thinking of making your own roles its easy to do, its best you create a plugin first. check up on some plugin boilerplates on github like this one https://github.com/DevinVinson/WordPress-Plugin-Boilerplate

then create edit your main file define the row first and the create a hook which activates the row when the plugin is installed. from there you will be able to use your custom role

$newrole = add_role(
     'basic_contributor',
      __( 'Basic Contributor' ),
      array(
      'read'         => true,  
      'edit_posts'   => true,
      'delete_posts' => false, 
      'publish_post'=> true
    )
);

function add_roles_on_plugin_activation() {
       add_role( 'custom_role', 'Custom Subscriber', array( 'read' => true, 
       'level_0' => true ) );
   }

register_activation_hook( __FILE__, 'add_roles_on_plugin_activation' );

if this could be a bit complex then install custom user row plugin from the wordpress repository from there you will be able to use in some cases for me if i am working on customising already developed plugins for different capability or permissions i use

if(current_user_can("basic-contributor") && is_user_logged_in(){

    //do this
    //show this
}