Because the regcode validation is built around hook_user, there is no way to implement custom validation unless the code is entered on a user edit/register form. For example, regcode_dynamic module sneaks its validation in ahead of regcode by implementing hook_user('validate') and setting its weight to -1. This is a neat approach, but it fails if the code is submitted elsewhere than on the user form - as it is sometimes by regcode_voucher (cf #797602: Voucher code in tab profile doesn't assign role). Hence, regcode_voucher has the following code at line 191:
if (module_exists('regcode_dynamic')) {
regcode_dynamic_user('validate', $edit, $account, 'account');
}
But what if another module wants to do custom validation?
Can there be a hook_regcode_validate() which is called directly from regcode_user_validate() to allow other modules to have their say? I would be happy to write the patch (would only be a line or two).
Thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | regcode-970554-2.patch | 1.44 KB | wodenx |
| #1 | regcode-970554.patch | 1.43 KB | wodenx |
Comments
Comment #1
wodenx commentedIn fact, here it is - simple as pie. Note this patch also includes a fix for #797602: Voucher code in tab profile doesn't assign role.
Comment #2
wodenx commentedActually - it probably makes sense to pass the $account object as well...
Comment #3
aidanlis commentedAwesome, thanks for the patch. Should be in the next release.