Change WordPress user roles and capabilities › Forums › New Feature Request › product reviews are now under products in woocommerce
- This topic has 8 replies, 2 voices, and was last updated 1 year, 11 months ago by bsahin.
-
AuthorPosts
-
08/09/2022 at 20:29 #8030bsahinParticipant
Hi there,
woocommerce seperated comments and product reviews.
But there is no setting in plugin.
I want my support people to edit reviews but can’t edit products.
I can’t do it now.09/09/2022 at 03:12 #8031VladimirKeymasterHi,
As workaround grant for such role: read, view_admin_dashboard, moderate_comments and edit product capabilities. But block “Products”, “All Products” menu items via “Admin menu blocking” add-on:
https://www.role-editor.com/block-admin-menu-items09/09/2022 at 13:11 #8032bsahinParticipantHello,
They can read reviews but they can’t approve, edit or delete them.
I tried what you said but I guess couldn’t make it.
https://prnt.sc/ZM9HTl5op50G09/09/2022 at 14:10 #8033VladimirKeymasterprnt.sc is not reachable for me. Did you add edit_products, edit_published_products, edit_others_products capabilities to make reviews editable for this role?
09/09/2022 at 19:51 #8034bsahinParticipantIt worked but they got capability to edit regular products. Even they can’t see these Products line in left panel, they can go a product and click edit above.
Which I don’t want them to do it.
I need them to edit only product reviews.13/09/2022 at 05:33 #8036VladimirKeymasterWC uses the same post type for the reviews – ‘product’. So we have to use additional code in order achieve your purpose. Working on you problem I found/fixed some bugs in the current version of URE Pro. So, download version 4.63.b1 from the “Downloads” page (login first).
1) Grant all product edit permissions to your role, test-role-1 in my example.
2) Block “Products” menu item for this role via “Admin Menu”.
3) Activate “Post/page edit restrictions” add-on: https://www.role-editor.com/allow-user-edit-selected-posts/
4) Set for user “Look at roles” at the “Posts/Pages/Custom Post Types Editor Restrictions” section.
5) Open “Post Edit” for your role and select “Prohibit” and “Products” post type.
6) Add code below to your active theme functions.php file or set up as a Must Use plugin:
add_filter('ure_restrict_edit_post_type', 'ure_edit_review_but_not_product', 10, 1 );
function ure_edit_review_but_not_product( $post_type ) {if ( $post_type!=='product') {
return $post_type;
}$user = wp_get_current_user();
if ( empty( $user ) || !in_array( 'test-role-1', $user->roles ) ) {
return $post_type;
}
if ( !isset( $_GET['page'] ) || $_GET['page']!='product-reviews' ) {
return $post_type;
}return false;
}
Replace ‘test-role-1’ above with your own role ID.As a result, user with full product edit permissions will can moderate reviews, but can not see/edit products at admin back-end.
13/09/2022 at 19:26 #8037bsahinParticipantmany thanks for solution.
Do you have plan to add this in next updates?
If yes, I will set reminder to remove special code from functions.php in future14/09/2022 at 02:39 #8038VladimirKeymasterI think, this is more specific case than universal one, in order to add it as a feature to the plugin. So I do not plan make this.
25/11/2022 at 12:46 #8110bsahinParticipantHi there,
Your above codes worked great.
But after these edits, I started to have PHP warning.[25-Nov-2022 12:40:44 UTC] PHP Warning: Trying to access array offset on value of type bool in /wp-content/plugins/user-role-editor-pro/pro/includes/classes/admin-menu-access.php on line 353
-
AuthorPosts
- You must be logged in to reply to this topic.