您可以使用WP_Role 班
// get the the role object
$role_object = get_role( $role_name );
// add $cap capability to this role object
$role_object->add_cap( $capability_name );
// remove $cap capability from this role object
$role_object->remove_cap( $capability_name );
因此,为了解决您最初提出的关于如何让管理员在帖子内容中输入脚本和IFRAME标记的问题,您正在寻找“unfiltered\\u html”功能,这在多站点中仅授予超级管理员。
// get the the role object
$admin_role = get_role( \'administrator\' );
// grant the unfiltered_html capability
$admin_role->add_cap( \'unfiltered_html\', true );
也可以在函数中运行一次:
/* Roles & Capabilities */
add_role(\'professional\', \'Professional User\', array(
\'read\' => true, // True allows that capability, False specifically removes it.
\'edit_posts\' => true,
\'delete_posts\' => true,
//\'edit_published_posts\' => true,
//\'publish_posts\' => true,
//\'edit_files\' => true,
\'upload_files\' => true //last in array needs no comma!
));