Job done - thanks very much to Kovid for the pointers.
Starson17 - yes that is exactly the behaviour. Depending on the sub-menu you select I build a unique list of authors/tags/series/publishers from the rows selected. Any that don't already exist in the user category are then added to it. As mentioned above the one minor issue is that you have to restart Calibre to get new user categories to appear in the menu but that is no big deal once you know that.
I've attached a screenshot, and probably tomorrow submit it in a day or two as a patch in case anything else comes up or other suggestions arise.