admin管理员组文章数量:1122832
One of our websites includes an online store, which alongside phone sales is one of two ways customers can purchase our products. All of our customer info is stored in a program called Orderwise, which assigns a unique number code to each customer. Now, we've set up the ability to add an Orderwise number to user info on the website, so I've been trying to set up a role which will allow the sales department to get through to the dashboard, but only so they can edit user info and add Orderwise numbers manually, and also view WooCommerce info such as orders. So I created a role with the following capabilities via a plugin;
edit_users
list_users
read
read_private_pages
read_private_posts
read_private_products
read_private_shop_coupons
read_private_shop_orders
read_private_shop_webhooks
read_product
read_shop_coupon
read_shop_order
read_shop_webhook
view_woocommerce_reports
I then assigned this role to a dummy test account and tried logging in with that via /wp-admin. This allowed me to login as a public site user, like our customers can, but not to access the dashboard and edit user info.
What capabilities am I missing from my role? Could any of these be conflicting with one another?
One of our websites includes an online store, which alongside phone sales is one of two ways customers can purchase our products. All of our customer info is stored in a program called Orderwise, which assigns a unique number code to each customer. Now, we've set up the ability to add an Orderwise number to user info on the website, so I've been trying to set up a role which will allow the sales department to get through to the dashboard, but only so they can edit user info and add Orderwise numbers manually, and also view WooCommerce info such as orders. So I created a role with the following capabilities via a plugin;
edit_users
list_users
read
read_private_pages
read_private_posts
read_private_products
read_private_shop_coupons
read_private_shop_orders
read_private_shop_webhooks
read_product
read_shop_coupon
read_shop_order
read_shop_webhook
view_woocommerce_reports
I then assigned this role to a dummy test account and tried logging in with that via /wp-admin. This allowed me to login as a public site user, like our customers can, but not to access the dashboard and edit user info.
What capabilities am I missing from my role? Could any of these be conflicting with one another?
Share Improve this question asked May 25, 2017 at 11:50 McOwenMcOwen 1421 gold badge1 silver badge9 bronze badges3 Answers
Reset to default 0I cracked it! I went ahead and duplicated an existing role, and trimmed off all of the guff I didn't think my sales role would need. In the end, I ended up with;
assign_product_terms
assign_shop_coupon_terms
assign_shop_order_terms
assign_shop_webhook_terms
connections_view_public
delete_others_products
delete_others_shop_coupons
delete_others_shop_orders
delete_others_shop_webhooks
delete_private_products
delete_private_shop_coupons
delete_private_shop_orders
delete_private_shop_webhooks
delete_product
delete_product_terms
delete_products
delete_published_products
delete_published_shop_coupons
delete_published_shop_orders
delete_published_shop_webhooks
delete_shop_coupon
delete_shop_coupon_terms
delete_shop_coupons
delete_shop_order
delete_shop_order_terms
delete_shop_orders
delete_shop_webhook
delete_shop_webhook_terms
delete_shop_webhooks
edit_others_products
edit_others_shop_coupons
edit_others_shop_orders
edit_others_shop_webhooks
edit_private_products
edit_private_shop_coupons
edit_private_shop_orders
edit_private_shop_webhooks
edit_product
edit_product_terms
edit_products
edit_published_products
edit_published_shop_coupons
edit_published_shop_orders
edit_published_shop_webhooks
edit_shop_coupon
edit_shop_coupon_terms
edit_shop_coupons
edit_shop_order
edit_shop_order_terms
edit_shop_orders
edit_shop_webhook
edit_shop_webhook_terms
edit_shop_webhooks
edit_users
list_users
manage_links
manage_product_terms
manage_shop_coupon_terms
manage_shop_order_terms
manage_shop_webhook_terms
manage_woocommerce
publish_products
publish_shop_coupons
publish_shop_orders
publish_shop_webhooks
read
read_private_pages
read_private_posts
read_private_products
read_private_shop_coupons
read_private_shop_orders
read_private_shop_webhooks
read_product
read_shop_coupon
read_shop_order
read_shop_webhook
unfiltered_html
view_woocommerce_reports
And, as if by magic, this new version of the sales role can now access the dashboard, with access only to the WooCommerce, Products and Users panes.
If anybody is interested, I have been using the inspiringly named User Role Editor plugin to create and edit user roles.
Your sales people probably don't need the unfiltered_html
capability.
Per https://codex.wordpress.org/Roles_and_Capabilities#unfiltered_html,
Allows user to post HTML markup or even JavaScript code in pages, posts, comments and widgets.
Note: Enabling this option for untrusted users may result in their posting malicious or poorly formatted code.
You don't need to provide access to WooCommerce to grant Dashboard Access. That's just how WooCoommerce likes it. You can use these functions to overwrite that:
function _wc_disable_admin_bar($prevent_admin_access) {
if (!current_user_can('customer') and !current_user_can('shop_manager')) {
return $prevent_admin_access;
}
return false;
};
add_filter('woocommerce_disable_admin_bar', '_wc_disable_admin_bar', 10, 1);
function _wc_prevent_admin_access($prevent_admin_access) {
if (!current_user_can('customer') and !current_user_can('shop_manager')) {
return $prevent_admin_access;
}
return false;
};
add_filter('woocommerce_prevent_admin_access', '_wc_prevent_admin_access', 10, 1);
本文标签:
版权声明:本文标题:woocommerce offtopic - Tried to create a user role that can only edit user information, but my test account cannot view the dash 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736283797a1927084.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论