Invalid argument supplied for foreach()
-
Hi,
Seeing a lot of this error from the plugin:
E_WARNING: Invalid argument supplied for foreach() …oup2019/wp-content/plugins/remove-admin-menus-by-role/remove-admin-menus-by-role.php (170) …enus_by_roles called at /wp-includes/class-wp-hook.php (287) …apply_filters called at /wp-includes/class-wp-hook.php (311) in WP_Hook::do_action called at /wp-includes/plugin.php (478) in do_action called at /wp-admin/admin-ajax.php (45)
which pertains to this line of code:
add_action( 'admin_init', 'remove_menus_by_roles' ); function remove_menus_by_roles() { //on récupère la configuration du profil $profile = get_remove_menu_admin_profile(); if($profile) { $roles_selected = unserialize($profile->roles); $menus_hidden = unserialize($profile->menus_hidden); $submenus_hidden = unserialize($profile->submenus_hidden); global $current_user; $user_role = $current_user->roles[0]; //si l'utilisateur connecté à un des roles sélectionnés if(in_array($user_role, $roles_selected)) { //on supprime les menus choisis if(sizeof($menus_hidden) > 0) { foreach($menus_hidden as $menu) LINE 170 --> remove_menu_page($menu); } if(@sizeof($submenus_hidden) > 0) { foreach($submenus_hidden as $submenu) { $data = explode('|', $submenu); //$submenu = menu|submenu remove_submenu_page( $data[0], htmlspecialchars($data[1]) ); } } } } }
Any chance of a fix? ??
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Invalid argument supplied for foreach()’ is closed to new replies.