Hi, I am having a problem to get correct value from "Token replacement patterns", when using Rules with User Register Form. Here is what I try to do: if an internal user (with my company email address) try to register, we don't save the registration info to Drupal, instead of, we redirect him to a page that tells "internal users don't need to register".
I created a rule based on "User register is being validated" event. The "Textual comparison" is checking the email field which is from User Register Form, to see if it's my company's email address. If it is, redirect to "internal users don't need to register" page.
The problem is I am not able to get the email value using Token. The only available Tokens are:
[form_id:string] The string, passed through check_plain
[form_id:string-raw] The string, raw and unfiltered Warning: Token value contains raw user input.
and Tokens for Acting user (which is not useful, since the user is not an acting user yet).
I tried [form_id:string] and [form_id:string-raw], but without luck. Could someone tell how can I get the email from User register form?
Thanks!!
Comments
Hello, does anybody has any
Hello, does anybody has any idea how to get the email from User register form? I tried all the ways I can found:
$form['nid']['#post']['mail']['0']['value']
$form_state['values']['mail']
$form['mail'][0]['#value']
...
But still not able to get it. Please help!
Try dpm() on $form
I'm no master on the structure of Drupal forms, but I recommend turning on the Devel module and PHP Filter modules (the latter in core). With these two you can do
<?phpdpm($form);
?>
Add a 'Execute custom PHP' action, and you can explore the available data more. (You'll also get a list of the available objects on the action configuration page -- it might even be that you should look in another object.)
In the cases where I have particular difficulties in finding the data I want I run a
<?phpdpm(get_defined_vars());
?>
Good luck!
//Johan Falk, NodeOne, Sweden
Thanks for the info. I have
Thanks for the info. I have added "dpm($form)" to the 'Execute custom PHP' action and was able to see the structure of the form array. However, I am still not able to get the value in the Textual comparison condition. If I add "dpm($form['account']['mail']['#value'])" to the 'Execute custom PHP' action, I was able to get the value.
Here are my two texts to compare:
$form['account']['mail']['#value']
[user:mail]
Here are Forms where events are activated:
User register
User profile form
One strange thing is: after the debug is turned on, I was only able to see the variable "acting user" is loaded. But no info for "form", "form_state", or "form_id" are turned on. I am not sure if this is the problem. Did I miss some configurations here?
Please help! Thanks!