WordPress.org

Forums

Admin Menu Editor
WooCommerce Permissions without Add Post permissions (7 posts)

  1. doublesharp
    Member
    Posted 9 months ago #

    The WooCommerce plugin uses a role of "Shop Manager" which I am locking down to only allow access to necessary menu items. I do not want this role to Add Posts, but they should be able to Add Coupons. When the "Add Posts" menu item is removed, the user is unable to add coupons as well. Some investigation shows that $this->get_current_menu_item(); is not returning the correct menu item (there is no menu item for "Add Coupon") and instead returns the "Add Post" item for which the role does not have permissions to modify.

    https://wordpress.org/plugins/admin-menu-editor/

  2. Janis Elsts
    Member
    Plugin Author

    Posted 9 months ago #

    I'm not very familiar with WooCommerce. How does one add coupons if there is no "Add Coupon" menu? Is it a button in the post editor or something like that? What is the address bar URL when you're adding a coupon (the plugin determines the current menu item based on the URL)?

    As an alternative approach, maybe you could try removing the "edit_posts" capability from the Shop Manager role with something like User Role Editor.

  3. doublesharp
    Member
    Posted 9 months ago #

    Sorry, that was a pretty terrible bug report. I am actually using User Role Editor, but it still isn't working, and from my debugging it seems to be that Admin Menu Editor thinks it is on a different page.

    In WooCommerce the Coupons are a custom post type, but they do not have the standard menus. There is only a link for "Coupons" which goes to the list view, and then you can click "Add Coupon" on the top of that page. When I debugged it, it seemed to think that I was trying to add a regular post, not the custom post type, and would not load the page. Adding the "Add Post" link back to the menu allows the "Add Coupon" post to load.

    Hopefully that makes more sense, if not let me know and I will give you further info. I will be out of town this weekend however so it will likely be next week before I can reply.

    Thanks!

  4. Janis Elsts
    Member
    Plugin Author

    Posted 9 months ago #

    All right, so which admin menu (if any) gets highlighted when you click "Coupons" or "Add Coupon"? Does this change if you deactivate AME?

    I'll also try installing WooCommerce sometime later and testing this myself.

  5. doublesharp
    Member
    Posted 9 months ago #

    Apologies, I've been swamped with work and haven't had a chance to follow up on this yet to any great extent.

    I did verify that the correct menu items are highlighted when the "Add Coupon" page is show (the "Coupons" menu link), and it seems to work after the plugin is disabled.

    I will follow up with more details as soon as I can.

  6. Janis Elsts
    Member
    Plugin Author

    Posted 9 months ago #

    All right, I was able to reproduce this problem on a test site and make a patch that partially fixes it. Try this version:
    http://downloads.wordpress.org/plugin/admin-menu-editor.zip

  7. doublesharp
    Member
    Posted 6 months ago #

    Apologies, I still haven't had a chance to test this patch. Finally digging out from all my workload and will check it out soon.

Reply

You must log in to post.

About this Plugin

  • Admin Menu Editor
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic