How to send email as per user choice ?

Ron 30 Apr, 2012
Hello,

I have a form with the following field:
<select name="currency" required="true" id="currency" onchange="setFlag(this.value)" style="font-family:Verdana, Geneva, sans-serif; width:280px; font-size:15px; border:1px solid #999;">
<option value="">Select an Option</option>
<option value="US Dollars">US Dollars</option>
<option value="Euro">Euro</option>
<option value="Ukrainian Hryvna">Ukrainian Hryvna</option>
<option value="Indian Rupees">Indian Rupees</option>
</select>  


I have four type of replies to be sent as per the users choice. How can I do this in chronoforms. I tried actions from greyhead.net but none of the email actions have a dynamic email field that can take a user email Example : {user_email}

Would you please help

Thanks
GreyHead 01 May, 2012
Hi Ron,

The Dynamic Email setting will work OK on either Email action provided that $form->data['user_email'] contains the user email.

Bob
Ron 01 May, 2012
Sorry Bob,

Your reply went over my head. There is no Dynamic field in "Email (GH)" and more over how will I add a criteria for a reply. I have to make the form send a reply as per the choice made in the dropdown. I do not know how to add a condition for the above form too. Please see the attachment

Please advice.

Thanks

Ron
GreyHead 02 May, 2012
Hi Ron,

From the Help tab:

The Dynamic and Static tabs have been merged into an Email Setup tab.
The boxes on the Email Setup tab will accept either a string e.g. [email]user@example.com[/email] or an input name in curly brackets {input_text_1}. This lets you mix and match static and dynamic values



To add a condition:

To make the sending the email conditional on the form data add an input name in curly brackets, a double colon ::, and a value to be matched e.g. {send_email}::1



So, if you want this email to be sent if they select Euros you would add {currency}::Euros.

This may not be the best way to handle the different Emails you want to send. If there are only small differences they may be easier to do with PHP in the Email template.

Bob
Ron 02 May, 2012
Hello Bob,

I am facing a problem the pickup code does not work in "Email(GH)" . It also does not work in any custom code. Either before or after email. The code is to pickup data from an array. But If I use the pickup code in normal Email fiels it works fine.

The code example:

    <?php
    $user_info =& $values[$form->data['username']];
    echo $user_info['email'];
    ?>


If it works okay in the normal email reply I hope it is not a bug. I am using the latest CF V4. Please see the screen shot.

Ron
GreyHead 03 May, 2012
Hi Ron,

Exactly what code are you using?

Bob
Ron 03 May, 2012

Hi Ron,

Exactly what code are you using?

Bob


Bob I feel this is a bug. Because I am using the same code. It works fine when I use the Email option. But when I use the Email[GH] it does not work.

I am going to send you a PM soon with the code.

thanks

Ron
GreyHead 04 May, 2012
Hi Ron,

Thanks for the PM, I asked my question badly. What do you have in the To address box of the Email [GH] action? It should probably be {email}.

Bob
Ron 04 May, 2012

Hi Ron,

Thanks for the PM, I asked my question badly. What do you have in the To address box of the Email [GH] action? It should probably be {email}.

Bob



Thanks for the reply Bob,

I have this custom code on top and OnSubmit: And in the To Email field I have {user_email}

<?php     
  $user =& JFactory::getUser();
  $form->data['user_email'] = $user->email;
?>
]I have also noticed that If there is an Email box before Email[GH] then the Email[GH] or any custom code after email does not pickup the values from the array. But If I move the Email[GH] above all but below custom code before email it works.

I do not understand this.

Thanks for the help
Ron
GreyHead 05 May, 2012
Hi Ron,

There was a bug in the standard Email action in some early releases of CFV4 that deleted the email info so that you couldn't use a second action. I thought that had been fixed but is sounds as though you are seeing the same problem. I haven't seen it reported recently.

Adding Debugger actions before and after the Email action would let you see any changes in the $form->data array.

Bob
Ron 23 May, 2012
Yes Bob this bug still exists. The "custom code after email" also does not work. This is really bothering work.

Hope to get a fix for it soon.

Thanks
Ron
GreyHead 23 May, 2012
Hi Ron,

I just checked, the email bug has been fixed and no data is lost.

The Custom code after email appears to work OK here.

Bob
Ron 24 May, 2012
I will download the latest version and test it. Thanks for the reply.

Best wishes

Ron
Ron 28 May, 2012
Hello Bob,

It does not work here. I installed and reinstalled CF V4 latest 3.3 but only one condition works. I I put the custom code before email it works but the email does not pickup as per the code and if I change the custom code does not pickup.

I think it is a bug.

Ron
GreyHead 28 May, 2012
Hi Ron,

It may be a bug - but I don't know where to look to find it. The simplest answer is probably not to use both Email actions, just use one or the other.

Bob
This topic is locked and no more replies can be posted.