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" ] } } ]
}
}