Okay, well, this is a little tricky to do, I think.
The complicated thing is to remember the position the player was at. It would be much easier and cleaner if you were making your own plugin instead.
It is possible using command blocks though.
My idea would be to spawn an invisible armor stand at the initial position of the player, that will act as the return point when the player has finished using spectator mode. The new problem that rises is to teleport the player to that exact armor stand and not the armor stand of another player who is currently venturing in spectator mode.
This can work if your server uses a whitelist. Because since you know all the players that can connect, you can tweak the settings of your system depending on the player using the command. This solution is far from being the sexiest. There may be a clever way to do this using command blocks but I am out of ideas on the question. If anyone has a way to do that efficiently, please enlighten me
I would still recommend you to code a plugin if you know the Java programming language. It is really easy to do using that.