Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

remove_menu_page(): E_WARNING: Invalid argument supplied for foreach()

$
0
0

Replies: 0

Hey,

While tracking the source of warnings constantly filling debug log found out it was due to the following line in this plugin:

remove-admin-menus-by-role.php:169:

foreach($menus_hidden as $menu)
  remove_menu_page($menu);

If you check remove_menu_page() reference, it says:

This function should be called on the admin_menu action hook. Calling it elsewhere might cause issues: either the function is not defined or the global $menu variable used but this function is not yet declared.

The correct code should be:

foreach($menus_hidden as $menu)
  add_action('admin_menu', remove_menu_page($menu));

Please consider.

Thanks

  • This topic was modified 6 minutes ago by unostar.

Viewing all articles
Browse latest Browse all 59525

Trending Articles