This forum is no longer open and is for reading/searching only.
Please use our new MachForm Community Forum instead.
MachForm Community Forums » MachForm 2
Conditional Emailing based on Country Field
Started 16 years ago by ricksterv4n1x8 | 2 posts |
-
I have a country field in all of our forms. Depending on which country the user selects I would like to send the form to a different recipient. I would like to define the email addresses for each possible country and have the form send based on that. Do you see this as possible? Thanks!
Posted 16 years ago # -
Hi,
Do you mean country field is Address field ? or drop down with country data ? we have similar post with this, you can find in here :
http://www.appnitro.com/forums/topic/email-from-a-drop-downlist?replies=9#post-2601
however you still need to change the form id and field/element id, depending on which field will become the conditional field. Here is the magic code :)
function form18_hook_email($params){ //change the email addresses below $email_list[1] = 'sales@example.com'; $email_list[2] = 'hrd@example.com'; $email_list[3] = 'support@example.com'; $email_list[4] = 'accounts@example.com'; $email_list[5] = 'legal@example.org'; $res = do_query("select element_3 from ap_form_{$params['form_id']} where id='{$params['entry_id']}'"); $row = do_fetch_result($res); $attn = $row['element_3_6']; $target_email = $email_list[$attn]; if(!empty($target_email)){ return $target_email; }else { return true; } }
if you use address field and get the condition from country data, you should change the array index. Since address is a sub field (sub 6) and not using numeric data, the change should be like this :
function form18_hook_email($params){ //change the email addresses below $email_list['Berlin'] = 'sales@example.com'; $email_list['Albania'] = 'hrd@example.com'; $email_list['Argentina'] = 'support@example.com'; $email_list['Italy'] = 'accounts@example.com'; $res = do_query("select element_3_6 from ap_form_{$params['form_id']} where id='{$params['entry_id']}'"); $row = do_fetch_result($res); $attn = $row['element_3']; $target_email = $email_list[$attn]; if(!empty($target_email)){ return $target_email; }else { return true; } }
You can see the element have sub id = 6 (element_3_6)
MachForm Support
Posted 16 years ago #
Reply
You must log in to post.