Forums

Custom Code with show stopper?

the_fitz 08 Aug, 2012
Hi all,

I have a form that I wish to display CONDITIONALLY...

I have this logic in a custom code event block before any other events.

<?php
$user =& JFactory::getUser();
$curr_id = $user->id;
$form->data['curr_id'];
$db =& JFactory::getDBO();
$query = "SELECT cf_id, secret_question, secret_answer, rm_id_link from jml_rex_registration WHERE cf_user_id = $curr_id";
$db->setQuery($query);
$reg_list = $db->loadAssoc();
$cf_id = $reg_list['cf_id'];
$rm_id_link = $reg_list['rm_id_link'];
$secret_question = $reg_list['secret_question'];
$secret_answer = $reg_list['secret_answer'];
$form->data['cf_id'] = $cf_id;
$query = "SELECT rex_card from jml_rex_main where rm_id = $rm_id_link ";
$db->setQuery($query);
$rex_main = $db->loadAssoc();
$rex_card = $rex_main['rex_card'];
if(!empty($rex_card)){
    echo "<div align='center'><h2>Link Card to My Account</h2>Card Number ". $rex_card." already is linked to an account. </div>";
    return;  // I WANT TO STOP PROCESSING HERE
   }
// I WANT TO CONTINUE PROCESSING HERE
?>


I thought that the "return;" would stop further processing, but I was wrong! The events following this code still fire.

How do I prevent the events that follow this code from continuing when a "$rex_card" value exists? I ONLY want the events to fire if there is a NULL value for the "$rex_card".

Thanks in advance for your help.
MrFitz
Max_admin 08 Aug, 2012
Hi MrFitz,

You should use a "Custom server side validation" action instead, returning "false" will run the "on fail" event where you can add a "Show stopper".

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
the_fitz 09 Aug, 2012
Thanks Max,

That worked like a charm!

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

VPS & Email Hosting 20% discount
hostinger