This article describes how to use functions related to user role creation in WordPress. in the WordPress multi-user mode, different roles have different permissions, for more information, see WordPress. WordPress has five user roles by default: "subscriber", "contributor", "author", "edit", and "administrator, however, the default five roles may not be enough for use. in this case, you can use the add_role () function to create a role.
Usage
add_role( $role, $display_name, $capabilities );
Parameters
$ Role
(String) (required) user role ID
Default value: None
$ Display_name
(String) (required) name of the user role displayed on the foreground
Default value: None
$ Capabilities
(Array) (optional) user role permissions
Default value: None
Return value
If the role ID does not exist and is created successfully, the WP_Role class is returned. if the role already exists or fails to be created, the system returns null.
Example
$ Result = add_role ('New _ role_created ', _ ('example of creating a user role', 'Bing '), array ('read' => true, 'edit _ posts' => true, 'delete _ posts' => false); if ($ result) echo 'user role created successfully! '; Else echo' creation failed because the user role already exists or for other reasons! ';
Others
This function is located in: wp-nodes des/capabilities. php
Although the WordPress user system looks very simple, it has a very strong scalability. using the plug-in, we can make WordPress user systems worse than professional Forum Systems.
User permission management is an important part of the user system. Although the permission design for these identities is very scientific, it still cannot meet the needs of everyone, this article will teach you how to customize the permissions of these identities.
First, install and enable the Capability Manager Enhanced plug-in and go to "User"> "Capabilities" for permission management.
Select New Role on the right, Select an identity for editing permissions, and then adjust permissions on the left.
Save the changes.