It's never a good idea to rely on nicks for restricted access, as the nick is the easiest item to change, and even if the network has services and those are configured to a quick kill if the password doesn't match, there's still a delay of (about) 30 seconds in which a person could use someone else's nick and get access.

I don't know why the code I provided isn't working for you.

Is the script on a bot, or your own client? If your client, move it to a bot, as that is what it is designed to work from.
Is the client opped in the channel? If not, op it.

Was a nick provided after the !register command? If not, provide one.
Was the nick that used the command opped? If not, they need to be.

I thought I had included messages to handle situations like above, however, limitations of this site prevent me from confirming this while I'm writing here.