Forums

Working with action email_gh

desertdiana 18 Jun, 2013
Hi,

I installed the email action and what I am trying to do is set this to send certain selected checkbox inputs to this email address. Do I use the condition field on the general tab?
Here is the actual form
https://ortl.org/volunteer-ortl.html

Here is what I tried and it didn't work.........I don't know php of course!

Thank you for helping me,

Diana
GreyHead 19 Jun, 2013
Hi Diana,

Please explain what you are trying to do here?

The Conditional box will only take one value (not a string of three) and it just turns the email on and off. I don't think that is what you want?

Bob
desertdiana 19 Jun, 2013
Hi Greyhead,

I want to have one email address that gets all the submitted information and then other email addresses that get only certain selected information form the checkboxes. Since I need to have the information added to a database, I set up the volunteer options as separate checkboxes.

Here is my events:
GreyHead 19 Jun, 2013
Hi Diana,

I don't really understand what you need here :-9

If you want emails with different content then you can use two copies of the email action. If you need to make one of then conditional of some checkboxes being set then you can use PHP in a Custom Code action to set a 'flag' that you can use in the Conditional box.

Bob
desertdiana 19 Jun, 2013
So I only need to use the normal email action and add a custom html/php action above it?

Where do I find the php code to add the flag? I don't know how to write php, should I know, but it really scares me!

Thank you for helping me!

Diana
GreyHead 20 Jun, 2013
Hi Diana,

Can you explain exactly what it is that you need to do - which input names and what happens to them?

Bob
GreyHead 25 Jun, 2013
Hi Diana,

Please try this (may need debugging):
<?php
$form->data['send_email'] = 0;
$check_array = array(
  'fundraising',
  'speaking',
  'youth',
  'fair_booths',
  'music_crafts',
  'publicity',
  'mall_tables',
  'other',
  'annual_contests'
);
foreach ( $check_array as $v ) {
  if ( isset($form->data[$v]) && $form->data[$v] ) {
    $form->data['send_email'] = 1;
  }
}
?>

Then use send_email::1 in the Email [GH] action conditional box.

Bob
desertdiana 25 Jun, 2013
Thank you Greyhead, I will try this out today!
desertdiana 25 Jun, 2013
Just tried this and I get this error...

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ']' in /home/ortlorg/public_html/administrator/components/com_chronoforms/form_actions/custom_code/custom_code.php(19) : eval()'d code on line 15
desertdiana 25 Jun, 2013
Hi Greyhead,

I got the php code fixed at stackoverflow. They aren't as nice as you but after they get done with making you feel like a looser, one does come through and tell you what is wrong.

Anyway here is the code that works: (line 15 had to remove the single quotes)

<?php
$form->data['send_email'] = 0;
$check_array = array(
  'fundraising',
  'speaking',
  'youth',
  'fair_booths',
  'music_crafts',
  'publicity',
  'mall_tables',
  'other',
  'annual_contests'
);
foreach ( $check_array as $v ) {
 if ( isset($form->data[$v]) && $form->data[$v] ) {
    $form->data['send_email'] = 1;
  }
}
?>


Many thanks and cheers to you Greyhead! Time for a beer!

Diana
GreyHead 25 Jun, 2013
Hi Diana,

Sorry about the extra quotes :-(

Bob

PS I will go back and fix my original post for other readers.
desertdiana 25 Jun, 2013
No problem Greyhead I couldn't even begin to write php. I tried to buy you a few beers, but Paypal said they couldn't complete my purchase at this time. I will try again......you deserve a cool one!

Kindest regards and major appreciation,

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