Thank you for the report! Unfortunately, I don’t think these short error messages have enough details to figure out which part of the plugin code cause the problem.
Do you have any more information about when/how these errors happen? For example, does it look like new errors show up every time you load a page, or is it just a couple of errors per day? Are there some pages that trigger more errors than others?
Edit: Also, have you made any changes to menu item permissions, especially the “Extra capability” setting?
-
This reply was modified 3 years, 2 months ago by Janis Elsts.
Hi, thank for your answer. Yes i know that’s not simple to determinate with precision what make this error.
This error appear a lot of times per day. First i was thinking that appear only when an admin is connected (because i’ve customize admin’s menu) but it’s not the case.
This error appear 4 up to 6 times per 5 minuts when someone is in the website.
WooCommerce customers included.
Yes i’m using a lot this “Extra capability” settings feature to customize more the menu, because i’ve 6 differents admin roles.
I’ve looked at WordPress source code (/wp-includes/capabilities.php
) and it looks like one way these errors can happen is if something tries to check whether the current user has a post-related capability without providing a post ID. The line numbers in the error messages suggest that it must be one of these capabilities:
edit_post
edit_page
delete_post
delete_page
Admin Menu Editor doesn’t use these capabilities by default, but it might need to check them if one of the admin menu items uses them. Do you know if any of the items in your menu use one of the above capabilities as an extra capability or a required capability?
Exact ! I’ve set many items with these exta capability like this item for example : image
Did you advise me to remove these 4 capabilities of all my extra capability ? Or that can be “fixed” ? :-/
These specific capabilities are something called “meta capabilities”. Normally, they’re not actually assigned to any roles or users. When checking if a user has one of these meta capabilities, WordPress core looks at the status and ownership or the post/page that’s being considered and substitutes a different capability, like edit_posts
, edit_others_posts
, edit_published_pages
and so on.
I would recommend using regular capabilities instead. For example:
edit_posts
edit_pages
delete_posts
delete_pages
It looks like the menu item in your screenshot is already using edit_pages
and not edit_page
, so that item shouldn’t be a problem. However, if any items are using edit_page
(without “s”), those settings need to be changed to edit_pages
.
This is the list of the capabilities what i’m using in “Extra capabilty” :
- manage_options
- edit_pages
- view_stats
- wpml_manage_translation_management
- manage_woocommerce
- manage_options
- install_plugins
- wpml_manage_string_translation
- edit_shop_coupon
- edit_users
- ure_create_capabilities
- exist
- delete_shop_coupon
I replace edit_shop_coupon
by edit_shop_coupons
AND delete_shop_coupon
by delete_shop_coupons
and that work !
I was put these capabilities because she was in the list, is it possible to excluded the capacilities from the list (like edit_page) to prevent this error in future ?
Thank you verry much for your help.
-
This reply was modified 3 years, 2 months ago by benoitfouc.
-
This reply was modified 3 years, 2 months ago by benoitfouc.
-
This reply was modified 3 years, 2 months ago by benoitfouc.
-
This reply was modified 3 years, 2 months ago by benoitfouc. Reason: resolved
All of those are probably fine. If I’m understanding this WordPress source code correctly, only the four capabilities that I listed before would trigger those specific error messages.
I made a small patch that could help fix these errors. Please try the development version of the plugin:
https://downloads.wordpress.org/plugin/admin-menu-editor.zip
Yes this is WooCommerce capabilities.
Okay i’ve put again edit_shop_coupon and delete_shop_coupon.
I’ve see the error.
I’ve try your dev version and the error desapear 🙂
Your fix working perfetcly !
Thank you
All right, that’s good. I’ll include this fix in the next plugin update.