Ok, this makes sense.
The feature is to check the validity of a registration code that either may be already expired when starting the registration process or when the user has submitting his data.
A code's individual expiry date is stored in a db table and a first AA Query shall just delete expired registration codes that will cause an error notification on that field of the form (onBeforeRegisterFormDisplay). That's already implemented and works just fine.
If the user is very slow a code may still be valid in the beginning of the registration processs but may have expired at submission time. The system is very picky, hence I like reject such attempts, too. So, I would need a second AA that does more or less the same check (and deletion) but most likely has to display an error message to the user (onBeforeUserRegistration).
From your explanation I'm not sure whether this would be an AA Query with an additional Output - echo php coded message (if that is supported by this trigger) or a AA Code?