Hopefuly I'm awake this time.

set %identonly $gettok($gettok($address($nick,5),1,64),2,33)
if (%identonly == $nick)

If the user is not properly identified, $nick will never equal ~userid.

I previously solved that problem by removing ~ from the userid as follows:

set %identonly $remove($gettok($gettok($address($nick,5),1,64),2,33),~)