Change order of custom submenu link in WP Admin?

Take a look at this function.

function my_submenu_order($menu_ord) {
    global $submenu;

    // echo '<pre>'.print_r($submenu,true).'</pre>';

    $arr = array();
    $arr[] = $submenu['users.php'][15]; // Your Profile
    $arr[] = $submenu['users.php'][10]; // Add New
    $arr[] = $submenu['users.php'][5]; // All Users
    $submenu['users.php'] = $arr;

    return $menu_ord;
}

add_filter('custom_menu_order', 'my_submenu_order');

Add that to your functions.php. It changes the default order of the user’s submenu from [5] [10] [15].

Now un-comment the echo and comment out everything else. This will output the menu item positions for everything. Look for your new submenu and add it to the list. So it would be something like this.

function my_submenu_order($menu_ord) {
    global $submenu;

    // echo '<pre>'.print_r($submenu,true).'</pre>';

    $arr = array();
    $arr[] = $submenu['users.php'][15];
    $arr[] = $submenu['users.php'][##]; // Add New Number
    $arr[] = $submenu['users.php'][10];
    $arr[] = $submenu['users.php'][5];
    $submenu['users.php'] = $arr;

    return $menu_ord;
}

add_filter('custom_menu_order', 'my_submenu_order');

EDIT

The above code works fine BUT if you were to add a plugin later that adds links to the Users submenu they wouldn’t show up because we are wiping out the original menu and not including the new links (because we don’t know what they are).

If that is a concern, instead of wiping out the menu we can add the newly sorted items to the end and remove the originals. See below.

function my_submenu_order($menu_ord) {
    global $submenu;

    // echo '<pre>'.print_r($submenu,true).'</pre>';

    // Build array of newly sorted items
    $arr = array();
    $arr[] = $submenu['users.php'][15]; // Your Profile
    $arr[] = $submenu['users.php'][10]; // Add New
    $arr[] = $submenu['users.php'][5]; // All Users

    // Remove the originals
    unset($submenu['users.php'][15]);
    unset($submenu['users.php'][10]);
    unset($submenu['users.php'][5]);

    // Add newly items to the list
    $submenu['users.php'] += $arr;

    return $menu_ord;
}

add_filter('custom_menu_order', 'my_submenu_order');