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

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #8030
    bsahin
    Participant

    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.

    #8031
    Vladimir
    Keymaster

    Hi,

    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-items

    #8032
    bsahin
    Participant

    Hello,

    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/ZM9HTl5op50G

    #8033
    Vladimir
    Keymaster

    prnt.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?

    #8034
    bsahin
    Participant

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

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

    #8037
    bsahin
    Participant

    many 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 future

    #8038
    Vladimir
    Keymaster

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

    #8110
    bsahin
    Participant

    Hi 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

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.