Title: Plugin throwing &#8220;undefined offset&#8221;
Last modified: January 18, 2017

---

# Plugin throwing “undefined offset”

 *  [mmcclanahan](https://wordpress.org/support/users/mmcclanahan/)
 * (@mmcclanahan)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/plugin-throwing-undefined-offset/)
 * After upgrading to version 1.7.3 of this plugin I started seeing the following
   errors in my log file:
 * PHP Notice: Undefined offset: 0 in /home/…/wp-includes/capabilities.php on line
   181
 * I believe that this caused by passing only a single argument to current_user_can.
   Note in the [documentation](https://codex.wordpress.org/Function_Reference/current_user_can)
   that ommiting this second $object_id argument will cause just this error. A scan
   confirmed that the plugin code was not using the $object_id argument.
 * Eventually I got a stack trace on this which pointed to Admin Menu Editor. I 
   confirmed by deactivating the plugin. The errors disappeared. I then downgraded
   to version 1.7.2. No issues there as well. The problem seems to be only in 1.7.3.
 * Thanks, Max

Viewing 1 replies (of 1 total)

 *  Plugin Author [Janis Elsts](https://wordpress.org/support/users/whiteshadow/)
 * (@whiteshadow)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/plugin-throwing-undefined-offset/#post-8667871)
 * Thank you for the report. However, it’s probably not as simple as a missing argument.
   Here’s why:
 * The $object_id argument is optional. It only needs to be used when calling current_user_can()
   on a meta capability like “edit_post”, in which case it specifies the post ID
   that the user is trying to edit. Normally, it makes no sense to use meta capabilities
   in the admin menu because the WordPress API for [creating admin menus](https://developer.wordpress.org/reference/functions/add_menu_page/)
   only accepts a single capability argument and has no way to set an $object_id.
   As a result, Admin Menu Editor usually doesn’t deal with meta capabilities, so
   it doesn’t need to use the $object_id argument.
 * That said, of course there’s always a risk that there could be a plugin conflict,
   a bug, or a configuration issue that causes AME to unintentionally use a meta
   capability.
 * Since you have a stack trace, can you please tell me the plugin file name and
   line number where this notice was triggered? Also, some PHP versions will log
   function arguments along with the stack trace, so do you know what capability
   the plugin was checking at the time?
    -  This reply was modified 9 years, 4 months ago by [Janis Elsts](https://wordpress.org/support/users/whiteshadow/).

Viewing 1 replies (of 1 total)

The topic ‘Plugin throwing “undefined offset”’ is closed to new replies.

 * ![](https://ps.w.org/admin-menu-editor/assets/icon-128x128.png?rev=1418604)
 * [Admin Menu Editor](https://wordpress.org/plugins/admin-menu-editor/)
 * [Support Threads](https://wordpress.org/support/plugin/admin-menu-editor/)
 * [Active Topics](https://wordpress.org/support/plugin/admin-menu-editor/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/admin-menu-editor/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/admin-menu-editor/reviews/)

## Tags

 * [capabilities](https://wordpress.org/support/topic-tag/capabilities/)
 * [error_log](https://wordpress.org/support/topic-tag/error_log/)

 * 1 reply
 * 2 participants
 * Last reply from: [Janis Elsts](https://wordpress.org/support/users/whiteshadow/)
 * Last activity: [9 years, 4 months ago](https://wordpress.org/support/topic/plugin-throwing-undefined-offset/#post-8667871)
 * Status: not resolved