function add_custom_editor_role(){
//sets a WordPress meta option if the role has already been set
$role_set = get_option('role_is_set');
if(!$role_set){
add_role(
'custom_editor',
__( 'Custom Editor' ),
array(
//wordpress
'read' => true,
'delete_posts' => true,
'delete_published_posts' => true,
'delete_published_pages' => true,
'edit_posts' => true,
'edit_pages' => true,
'edit_published_pages' => true,
'edit_others_pages' => true,
'edit_others_posts' => true,
'edit_pages' => true,
'edit_private_pages' => true,
'edit_private_posts' => true,
'edit_published_pages' => true,
'edit_published_posts' => true,
'read' => true,
'read_private_pages' => true,
'read_private_posts' => true,
'publish_pages' => true,
'publish_posts' => true,
'upload_files' => true,
//woocommerce
'manage_woocommerce' =>true,
'assign_product_terms' => true,
'delete_others_products' => true,
'delete_private_products' => true,
'delete_product' => true,
'delete_product_terms' => true,
'delete_products' => true,
'delete_published_products' => true,
'edit_others_products' => true,
'edit_private_products' => true,
'edit_product' => true,
'edit_product_terms' => true,
'edit_products' => true,
'edit_published_products' => true,
'manage_product_terms' => true,
'publish_products' => true,
'read_private_products' => true,
'read_product' => true,
)
);
update_option('role_is_set',true);
}
}