Simple Python script - Adding a primitive object to the active layer
right click on the add cube icon and then click Pie Menu Editor.



then it will ask you in which menu you want to put it.



by default the the arguments for layers are all False


so unless you specify one it will always create the cube in the activate layer