I have a Drupal 7 site with the Honeypot module installed. Honeypot removes or prevents many spam registrations, but not all. I have extra fields added to the profile e.g. 'profile_field1'. I'd like to build a rule using the Rules modules that either deletes an account or prevents it from being created if the content of the 'profile_field1' doesn't match a certain regular expression. I cannot find how to create a rule that can handle an extra profile field. What I'd like to create:

'before saving a new user account'
if profile_field1 does not match RegExPattern
then prevent account from being created

I can find how to create a condition based on the 'regular' fields in the account (such as the name), but I cannot find how to test for the extra fields.

Update 1: the field 'profile_field1' is part of the Users profile, i.e. the Drupal Profile module is enabled. This module is part of D7 and similar in functionality to drupal.org/project/profile (for D8). It's found in [drupal]/modules/profile. Configuration settings are in admin/config/people/profile.

Update 2: I checked in the database. There is no table called 'profile_field1'. The info is in 'profile_field' which defines all fields and in profile_value, which contains all values. So, e.g. profile_field1 would be fid=1 in table profile_field. Then user 5 (uid = 5) would have a record in profile_value with fid = 1, uid = 5, value = 'content of field'.

Update 3: With the suggestions in the answer I was able to migrate the information from the old Profile to the Profile2 fields. Write up is here: https://www.drupal.org/node/2916659

Update 4: At least I can create a Rules rule now. Just wondering if this is the best:

{ "rules_prevent_spam_registration" : {
    "LABEL" : "Prevent spam registration",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "user_presave" : [] },
    "IF" : [
      { "entity_has_field" : {
          "entity" : [ "account-unchanged:profile-personal" ],
          "field" : "field_profile_field1"
      { "AND" : [
          { "text_matches" : {
              "text" : [ "account-unchanged:field-profile-field1" ],
              "match" : "<regexPattern>",
              "operation" : "regex"
    "DO" : [ { "entity_delete" : { "data" : [ "account-unchanged" ] } } ]
  • Since your question is about D7, the profile module cannot be drupal.org/project/profile ... which only exists for D8. Can you edit your question again, to include the URL of "your" profile module? PS: I do not like the "chat"-interface on drupal.SE, sorry. Oct 16, 2017 at 17:30
  • chat: no problem. Question updated
    – hepabolu
    Oct 16, 2017 at 17:36
  • Please review the edit I applied to the title of your question (to make it more accurate). If you don't like it, just perform a rollback. Also check my updated answer ... something like "as good as it gets"? Oct 16, 2017 at 18:16

1 Answer 1


With the limited info provided in your question, the best bet is that you cannot test for that extra field because you forgot to add a Rules Condition like "entity has field" (related to your profile_field1 field). So add that Rules Condition first (as your very first Rules Condition), and then try again.

For a video tutorial that illustrates the importance of this Entity has field condition, refer to Data types and data selection, especially what is shown between about 13:30 and 17:30 in it.


As per your updates to your question, I now understand that you're using the deprecated (core) profile module. This is a quote from its .info file:

; The Profile module is deprecated, and included in Drupal 7 for legacy

; purposes only. By default, the module will be hidden from the UI unless you

; are upgrading a site that uses the Profile module to extend user profiles.

Because of that, I doubt that there is a way to use the Rules module to check "if the content of the 'profile_field1' doesn't match a certain regular expression" (as in your question). Mostly because the Rules Condition like "entity has field" (= typical prereq to configure these kinds of Rules Conditions) will not have any effect for such profile_field1-field. Maybe not the answer you would want to hear/read, but I'm afraid it explains that what you're asking for cannot be done with Rules.


Give it some thought to consider switching to the Profile 2 module. Quote from its project page:

Designed to be the successor of the core profile module, which is deprecated for Drupal 7. In contrast to the deprecated module this module provides a new, fieldable 'profile' entity - leverage the power of fields!


... Thanks to the foundational entity API the module integrates well with Rules ...

If you do, pretty sure my original answer (= add a Rules Condition like "entity has field") will turn out to be the solution for what you try to achieve.

  • Well, I tried that but there is no way to select the field 'profile_field1'. If I use 'entity has field' and I choose either 'account' or 'account-unchanged' I can select all kinds of fields that are part of my content types, but I cannot select 'profile_field1'. And since it's a drop down list, I cannot add it manually
    – hepabolu
    Oct 16, 2017 at 16:41
  • @hepabolu please EDIT your question to include an EXPORT of the rule you have so far. It may help to further improve my answer also. Oct 16, 2017 at 16:45
  • I'd love to but so far I have nothing, other than the event
    – hepabolu
    Oct 16, 2017 at 16:57
  • that is what I feared ... next attempt: where does that field come from, how is it configured, some module that created it? Oct 16, 2017 at 17:00
  • Thanks for sticking with me. It's added in admin/config/people/profile. It's configured as a text field, private field, but visible at user registration, user must enter a value. I think it's standard Drupal.
    – hepabolu
    Oct 16, 2017 at 17:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.