如果已创建自定义角色以添加新功能,请将此代码添加到这些功能中。php
function add_theme_caps(){
global $pagenow;
// gets the author role
$role = get_role( \'teacher\' );
$role2 = get_role( \'school\' );
if ( \'themes.php\' == $pagenow && isset( $_GET[\'activated\'] ) ){ // Test if theme is activated
// Theme is activated
// This only works, because it accesses the class instance.
// would allow the author to edit others\' posts for current theme only
$role->add_cap( \'upload_files\' );
$role2->add_cap( \'upload_files\' );
}
else {
// Theme is deactivated
// Remove the capability when theme is deactivated
$role->remove_cap( \'upload_files\' );
$role2->remove_cap( \'upload_files\' );
}
}
add_action( \'load-themes.php\', \'add_theme_caps\' );
Dactivate和active主题进行更改