Hooking in to the email verificatin process In Drupal 7 (7.22), we'd like to hook into the email verification process for new users.  Perhaps the one time password node.  We need to do a test on the email address and set a value in a custom user field based on what we find.  This will allow us to give software activation terms to users with email matching certain business partner domains, for example.

Extra credit: we'd also like to enable a particular role for these users.  The first step, though, is to figure out where to hook in our php to do a regex test of $user->mail.
It would make more sense to create a rule to activate on After saving new user account. You could do a Text comparison on Account:mail using your regular expression, and if the condition was TRUE, Assign a role for the  new user. It would be waiting for them when they verified their account.

If your requirements change for the site, it is easier to make an alteration through the UI than it is to track down the code that has to be changed.

The same rule can Set a data value in the custom user field if you wish.

EDIT:

Install and activate the Rules module. Then go to /admin/config/workflow/rules and create a new rule,  calling it, lets say 'Upgrade new user' and set it to react on After saving a new user account.

When the configuration screen comes up Add condition and select Text comparison (wait for the AJAX request to complete) then set the Data selector to account:mail. Under Matching Text, click the Switch to direct input button, enter your regular expression in the  Value box, and at the bottom use Regular expression for the Comparison operation. Then save the condition.

Then add two actions; First add Add user role (wait for the ajax to complete) and you should see account as your data selector. Then choose the role(s) to add and save the action.

Then add an action to Set a data value. In the Data selector, find your field, and click Continue. In the Value box using &lt;?php ... ?&gt; delimiters, enter the code you need to return your activation key.

Save everything and try it out.