역할 편집자가 workdress에서 woocommerce 분류를 관리할 수 있도록 하려면 어떻게 해야 합니까?
Editor 역할에서 모든 woocommerce 관리에 액세스할 수 있도록 하고 싶습니다.이 역할에 기능을 추가하여 이 작업을 수행할 수 있었습니다.
$role = get_role( 'editor' );
$role->add_cap( 'manage_woocommerce_products' );
$role->add_cap( 'manage_woocommerce_taxonomies' );
$role->add_cap( 'manage_woocommerce_orders' );
$role->add_cap( 'manage_woocommerce' );
$role->add_cap( 'view_woocommerce_reports' );
$role->add_cap( 'manage_woocommerce_coupons' );
$role->add_cap( 'edit_product' );
$role->add_cap( 'read_product' );
$role->add_cap( 'delete_product' );
$role->add_cap( 'edit_products' );
$role->add_cap( 'publish_products' );
$role->add_cap( 'read_private_products' );
$role->add_cap( 'delete_products' );
$role->add_cap( 'delete_private_products' );
$role->add_cap( 'delete_published_products' );
$role->add_cap( 'edit_private_products' );
$role->add_cap( 'edit_published_products' );
$role->add_cap( 'edit_products' );
상품 카테고리나 태그 이외에는 모두 정상적으로 동작하고 있는 것 같습니다만, 검색해 본 것은 아무것도 없습니다만, 어느 것이 기능하고 있는지는 모르겠습니다만, 어느 쪽의 전문가가 안내해 주셨으면 합니다.
정말 감사해요.
프로그래밍 방식으로도 이 작업을 수행할 수 있지만, 이 작업을 수행하려면 몇 가지 역할을 더 부여해야 합니다.
Woocommerce Shop Manager 역할을 조회하여 편집자 역할과 기능을 비교하여 확인하였습니다.
전체 로트를 추가하는 코드는 다음과 같습니다(작성 시).
//add caps to editor role
$role = get_role("editor");
//for woocommerce
$role->add_cap("manage_woocommerce");
$role->add_cap("view_woocommerce_reports");
$role->add_cap("edit_product");
$role->add_cap("read_product");
$role->add_cap("delete_product");
$role->add_cap("edit_products");
$role->add_cap("edit_others_products");
$role->add_cap("publish_products");
$role->add_cap("read_private_products");
$role->add_cap("delete_products");
$role->add_cap("delete_private_products");
$role->add_cap("delete_published_products");
$role->add_cap("delete_others_products");
$role->add_cap("edit_private_products");
$role->add_cap("edit_published_products");
$role->add_cap("manage_product_terms");
$role->add_cap("edit_product_terms");
$role->add_cap("delete_product_terms");
$role->add_cap("assign_product_terms");
$role->add_cap("edit_shop_order");
$role->add_cap("read_shop_order");
$role->add_cap("delete_shop_order");
$role->add_cap("edit_shop_orders");
$role->add_cap("edit_others_shop_orders");
$role->add_cap("publish_shop_orders");
$role->add_cap("read_private_shop_orders");
$role->add_cap("delete_shop_orders");
$role->add_cap("delete_private_shop_orders");
$role->add_cap("delete_published_shop_orders");
$role->add_cap("delete_others_shop_orders");
$role->add_cap("edit_private_shop_orders");
$role->add_cap("edit_published_shop_orders");
$role->add_cap("manage_shop_order_terms");
$role->add_cap("edit_shop_order_terms");
$role->add_cap("delete_shop_order_terms");
$role->add_cap("assign_shop_order_terms");
$role->add_cap("edit_shop_coupon");
$role->add_cap("read_shop_coupon");
$role->add_cap("delete_shop_coupon");
$role->add_cap("edit_shop_coupons");
$role->add_cap("edit_others_shop_coupons");
$role->add_cap("publish_shop_coupons");
$role->add_cap("read_private_shop_coupons");
$role->add_cap("delete_shop_coupons");
$role->add_cap("delete_private_shop_coupons");
$role->add_cap("delete_published_shop_coupons");
$role->add_cap("delete_others_shop_coupons");
$role->add_cap("edit_private_shop_coupons");
$role->add_cap("edit_published_shop_coupons");
$role->add_cap("manage_shop_coupon_terms");
$role->add_cap("edit_shop_coupon_terms");
$role->add_cap("delete_shop_coupon_terms");
$role->add_cap("assign_shop_coupon_terms");
$role->add_cap("edit_shop_webhook");
$role->add_cap("read_shop_webhook");
$role->add_cap("delete_shop_webhook");
$role->add_cap("edit_shop_webhooks");
$role->add_cap("edit_others_shop_webhooks");
$role->add_cap("publish_shop_webhooks");
$role->add_cap("read_private_shop_webhooks");
$role->add_cap("delete_shop_webhooks");
$role->add_cap("delete_private_shop_webhooks");
$role->add_cap("delete_published_shop_webhooks");
$role->add_cap("delete_others_shop_webhooks");
$role->add_cap("edit_private_shop_webhooks");
$role->add_cap("edit_published_shop_webhooks");
$role->add_cap("manage_shop_webhook_terms");
$role->add_cap("edit_shop_webhook_terms");
$role->add_cap("delete_shop_webhook_terms");
$role->add_cap("assign_shop_webhook_terms");
그러면 모든 에디터에 대해 woocommerce에 FULL 기능이 추가됩니다.
추가 역할이 필요하지 않은지 확인하려면 다음과 같이 숍 매니저 역할에 부여된 기능과 비교합니다.
$role = get_role("shop_manager");
print_r($role->capabilities);
이 글을 읽으시면 woocommerce가 2개의 플러그인으로 동작하도록 권장하고 있음을 알 수 있습니다.이것 또는 이것
또는 이 기능을 추가해 보십시오.
- manage_product_module
- edit_product_module
- delete_product_module
- assign_product_module
- manage_카테고리
죄송해요, 파티에 좀 늦어서요.사용자 역할 디버깅을 위해 이 스니펫을 공유하려고 했는데 큰 도움이 되었습니다.
add_action( 'admin_notices', 'debug_user_roles' );
function debug_user_roles() {
global $pagenow;
if( $pagenow == 'index.php' ) {
$MYrole = get_role("seo_specialist");
echo '<pre>';
print_r($MYrole->capabilities);
echo '</pre>';
$MY_other_role = get_role("shop_manager");
echo '<pre>';
print_r($MY_other_role->capabilities);
echo '</pre>';
}
}
그러면 wp-dashboard에 사용자 역할의 기능이 표시됩니다.또, 다음과 같은 것을 추가할 수도 있습니다.if
current_user_can('administrator')
필요하다면
언급URL : https://stackoverflow.com/questions/27822458/how-to-allow-a-role-editor-to-manage-woocommerce-taxonomies-in-worpdress
'programing' 카테고리의 다른 글
리액트 테스트 라이브러리를 사용할 때 구성 요소가 올바른 소품으로 렌더링되는지 테스트하는 방법은 무엇입니까? (0) | 2023.04.04 |
---|---|
Json 태그는 있지만 내보내지 않음 (0) | 2023.04.04 |
src/main/resources 폴더에서 프리마커 템플릿 파일을 읽는 방법 (0) | 2023.04.04 |
Wordpress admin menu messed (0) | 2023.04.04 |
TypeScript에서는 다양한 열거형이 어떻게 동작합니까? (0) | 2023.04.04 |