WordPress开发者和主题制作者的搜索引擎



add_role ›

Since2.0.0
已弃用n/a
add_role ( $role, $display_name, $capabilities = array() )
参数: (3)
  • (string) $role Role name.
    Required: Yes
  • (string) $display_name Display name for role.
    Required: Yes
  • (array) $capabilities List of capabilities, e.g. array( 'edit_posts' => true, 'delete_posts' => false );
    Required: No
    默认: array()
返回:
  • (WP_Role|null) WP_Role object if role is added, null if already exists.
定义在:
文档:

Add role, if it does not exist.



源码

function add_role( $role, $display_name, $capabilities = array() ) {
	if ( empty( $role ) ) {
		return;
	}
	return wp_roles()->add_role( $role, $display_name, $capabilities );
}