[resolved] Re-ordering the Admin Menu - made an attempt (3 posts)

  1. BunnyBomb
    Posted 3 years ago #


    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!

  2. BunnyBomb
    Posted 3 years ago #

    Bah...I know what I have to do, just don't know how to do it. Logic tells me I need the if statement for the "if user isn't an editor" part around both the menu_order_filter function and the add_filter call. Somehow...

  3. BunnyBomb
    Posted 3 years ago #

    Got it! Logic wins again.


Topic Closed

This topic has been closed to new replies.

About this Topic