• Resolved BunnyBomb

    (@bunnybomb)


    Hello,

    I’ve made an attempt to re-order the Admin menu for non-Admin users.

    It is working when I login as Editor or below and looks great, no errors. But, I’m getting a strange error when I login as Admin.

    Code I am using (9 lines):

    function menu_order_filter($menu) {
    	if(!current_user_can('add_users')) {
    		$dev_menu = array('edit.php?post_type=pet','separator1', 'edit.php', 'edit.php?post_type=page', 'separator2');
    		array_splice($menu, 1, 0, $dev_menu);
    		return array_unique($menu);
    	}
    }
    add_filter('custom_menu_order', create_function('', 'return true;'));
    add_filter('menu_order', 'menu_order_filter');

    Error when logged in as Admin:
    Warning: array_flip() expects parameter 1 to be array, null given in C:\xampp\htdocs\wordpress\wp-admin\includes\menu.php on line 193

    The error doesn’t prevent WordPress from loading or functioning. It just appears at the top of the Dashboard when logged in as “admin”, as a line of text at the top.

    I’m not an experienced coder so expect I’ve done something basic wrong. Would appreciate some advice!

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Re-ordering the Admin Menu – made an attempt’ is closed to new replies.