Drupal 7: cancel user registration if a wrong field value has been submitted.

Posted by Alexander Farber on Stack Overflow See other posts from Stack Overflow or by Alexander Farber
Published on 2011-03-06T14:06:59Z Indexed on 2011/03/07 8:10 UTC
Read the original article Hit count: 310

Hello,

I have a Drupal 7 with 1 field added to registration form - a List with possible values Robot / Male / Female: enter image description here

# select * from field_data_field_gender;
 entity_type | bundle | deleted | entity_id | revision_id | language | delta | field_gender_value
-------------+--------+---------+-----------+-------------+----------+-------+--------------------
 user        | user   |       0 |         6 |           6 | und      |     0 | Male
 user        | user   |       0 |         5 |           5 | und      |     0 | Male
 user        | user   |       0 |         7 |           7 | und      |     0 | Female
 user        | user   |       0 |         1 |           1 | und      |     0 | Male

The first value Robot is a default value - to prevent SPAM robots from registering at my site. Is there a way to cancel user registration, when a new user submits the registration web form with the default Robot value? (i.e. only Male and Female values are allowed).

I've looked at the core Trigger module, but don't see anything suitable there.

I've looked at the hook_user_presave and hook_user_insert API docs, but don't see a way there to cancel an ongoing user registration. (I was expecting to do that by returning a special value from those methods...)

Thank you! Alex

© Stack Overflow or respective owner

Related posts about drupal

Related posts about drupal-7