Conditional Email on submit issue

dksf 13 May, 2014
I'm using Joomla 2.5.20 and Chronoforms 4. I have a form which I've setup to conditionally send out an email based on a field value and then process with additional custom code which isn't working.

The On Submit events are
1. Load User Info [GH]
2. Data To Session
3. Custom Code - Conditional Email
<?php
if ( isset($form->data['status'] && $form->data['OFF'] ) {
  $form->data['send_email'] = 1; 
} else {
  $form->data['send_email'] = 0;
}
?>

4. Email [GH] - Condition = {send_email}::1
5. Custom Code
<?
//echo "<LI>HEX".$hex_string;
function strToHex($string){
    $hex = '';
    for ($i=0; $i<strlen($string); $i++){
        $ord = ord($string[$i]);
        $hexCode = dechex($ord);
        $hex .= substr('0'.$hexCode, -2);
    }
    return strToUpper($hex);
}
if($_POST['status'] == 'ON')
{
$sso_string = "SML".$_POST['MembershipID']."X".$_POST['ClientMemberID']."EL";
$hex_string = strToHex($sso_string);
header('Location: https://mysite.com/?ocx='.$hex_string);
}
else{
//$options = $_POST;
while(list($key, $value) = each($_POST))
{
if(!empty($value))$params[$key] = $value;
}


My conditional emails aren't being being sent out and I'm getting the following error on the else portion of the last custom code action if th.

Fatal error: Cannot use object of type JParameter as array in /var/www/vhosts/mysite.com/httpdocs/administrator/components/com_chronoforms/form_actions/custom_code/custom_code.php(19) : eval()'d code on line 21

Line 21 - if(!empty($value))$params[$key] = $value;

If the following is true if($_POST['status'] == 'ON') the code works.

I can use the curl option and post my form to an external file with the same code in my custom code action and it works (no emails though).

Does anyone have any suggestions on what the issue is? I've read a few posts that seem to point to Joomla and the use of JParameter depreciating.

Thanks
Max_admin 14 May, 2014
You can try this FAQ which works fine with the default Email action:
https://www.chronoengine.com/faqs/57-cfv4/cfv4-actions/2643-how-to-send-an-email-dynamically.html

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
dksf 14 May, 2014
Thanks for the tip Max.

Reworking the email action didn't resolve my other issue with the JParameter array. Any thoughts on this?
dksf 14 May, 2014
Thanks Max.

I've solved the conditional email issue. I'll open a new topic regarding the JParameter issue.
This topic is locked and no more replies can be posted.