HI guys,
I'm new to rules an am stuck on an issue. I am using rules_forms to process some input from a form. I'll describe what I am trying to achieve and hopefully someone can help.
1) My client wishes to prevent any user with a free email account from posting through the contact form.
2) I have set up a rule that triggers on form validation and prints and error for the email field.
I tried to achieve the logic with text-compare, but it's not working for some reason , so I am going down the php route.
Essentially I have a regular expressions:
[a-zA-Z0-9_.]+@(gmail|yahoo|hotmail)(.[a-z]{2,3}){1,2}
That will check if the email contains, yahoo , gmail etc..
when setting up the rule with the text compare I was able to use the token: submitted[email] : to get the value of the email address.
In a nutshell, how do I access the value provided by this token in PHP so I can manually run my regex or any other logic against the email address field.
Any help appreciated, confused and frustrated - I haven't been able to find much documentation pertaining to forms/php with rules.
Many thanks
Hix
Comments
I don't know if you need to
I don't know if you need to use the rules module for this. If you go to /admin/user/rules on your site there are user access rules already provided that allow you to deny based on a mask.
-
@foggyperspectiv | foggyperspective.com (blog)
Hi Caschbre, Thanks for the
Hi Caschbre,
Thanks for the reply.
The access rules for users are only for login & account creation, I require this functionality on a site wide contact form.
Lightflows, Web Development Agency
Has anyone used an PHP with
Has anyone used an PHP with Rules forms? That may give me a head start
Lightflows, Web Development Agency
Has anyone used any PHP with
Has anyone used any PHP with Rules forms? That may give me a head start
Lightflows, Web Development Agency
This isn't specific to your
This isn't specific to your situation, but it might shed some light on using the Execute Custom PHP Code condition.
--
Less isn't more; just enough is more.
- Milton Glaser
Sorry, that should have
Sorry, that should have included http://groups.drupal.org/node/25672
--
Less isn't more; just enough is more.
- Milton Glaser
Just a validate function?
I'm usually not the guy who suggests manual coding over a module, but in this case it seems you're just looking for a complementary validation function for the comment form.
This could be a mini module, instead of a Rules function.
It seems you will have to do some coding – to get the regexp into Rules – so you won't get a no-coding solution anyway. If you make it a mini module you have just some few lines surrounding the expression you want to test, and you don't have to worry about the framework of Rules nor Token. Just hook into the variables.
Hope this might help.
//Johan Falk, NodeOne, Sweden