Change WordPress user roles and capabilities Forums New Feature Request product reviews are now under products in woocommerce Reply To: product reviews are now under products in woocommerce

#8036
Vladimir
Keymaster

WC 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.