你想要的是add_role()
这个Codex provides sample code:
$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.\';
}