remove_menu_page(): E_WARNING: Invalid argument supplied for foreach()
-
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
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘remove_menu_page(): E_WARNING: Invalid argument supplied for foreach()’ is closed to new replies.