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

CommentFileSizeAuthor
#2 regcode-970554-2.patch1.44 KBwodenx
#1 regcode-970554.patch1.43 KBwodenx

Comments

wodenx’s picture

Status: Active » Needs review
StatusFileSize
new1.43 KB

In 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.

wodenx’s picture

StatusFileSize
new1.44 KB

Actually - it probably makes sense to pass the $account object as well...

aidanlis’s picture

Status: Needs review » Fixed

Awesome, thanks for the patch. Should be in the next release.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.