Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm trying to implement hook_regcode_validate, and have just used the example code from regcode.api.php, taking out the if statement:
function my_module_regcode_validate($edit, $account) {
form_set_error('regcode_code', t('This just isn\'t working out between us.'));
}
I would expect this to stop the registration form validating in all cases and the message above being displayed. It does not appear to have any effect. Am I doing something wrong or expecting the wrong outcome from regcode_validate? Is there an alternative way to add additional validation to the use of a registration code on user registration?
Comment | File | Size | Author |
---|---|---|---|
#2 | 2231149-2-remove-hook-regcode-validate-documentation.patch | 501 bytes | TR |
Comments
Comment #1
Matt BMy workaround is to do something like this:
Comment #2
TR CreditAttribution: TR commentedhook_regcode_validate()
was removed from the 7.x-1.x version of this module - it was only present in Drupal 6. I don't know why it was removed, but I guess it was becausehook_user()
was re-written in the D6->D7 transition. See #118345: Revamp hook_user_form/_register/_validate/_submit/_insert/_update. Because there's an alternative way to accomplish this viahook_form_alter()
(similar to what #1 shows), the maintainer might have decided not to bother with a hook anymore.The regcode.api.php file evidently never got updated.
Here's a patch to remove the outdated documentation from regcode.api.php.
Comment #5
TR CreditAttribution: TR commentedCommitted #2.