Hi,
I have 2 forms 1 for registering and another for logging in. I'd like to show either depending upon a users registration status which is being pulled from the database. I've read a few posts that describe doing this but they were kind of old. Seems like the best option would be to use events or greyheads Event Switcher but I can't wrap my head around how. Would I combine the two forms into one? Can I call up one form or the other using events? Can anyone walk me through the process or point me to some documentation on how to achieve this?
Thanks
I have 2 forms 1 for registering and another for logging in. I'd like to show either depending upon a users registration status which is being pulled from the database. I've read a few posts that describe doing this but they were kind of old. Seems like the best option would be to use events or greyheads Event Switcher but I can't wrap my head around how. Would I combine the two forms into one? Can I call up one form or the other using events? Can anyone walk me through the process or point me to some documentation on how to achieve this?
Thanks
Hi dksf,
Sorry but I don't understand what you are trying to do here. How do you check a User's registration status if they aren't logged in yet?
Bob
Sorry but I don't understand what you are trying to do here. How do you check a User's registration status if they aren't logged in yet?
Bob
Hi,
To clarify, it's not a joomla registration or login form. The registration is for external service. When a user registers for this service a membership number is written to the database. I'd like to show only one form to a user based on the weather or not they've registered for it. They would already be logged into joomla.
To clarify, it's not a joomla registration or login form. The registration is for external service. When a user registers for this service a membership number is written to the database. I'd like to show only one form to a user based on the weather or not they've registered for it. They would already be logged into joomla.
Hi dksf,
OK - so if they are already logged in then - presumably - you have their user id tied to the registration ??? (If not then I'd suggest that you add it).
There are several ways to do this. The simplest is probably to use three forms. The first form will only have an on-load section and will:
a) Check their User ID and look up their registration
b) Redirect them to another form depending on whether the registration is found or not
One Custom Code action like this will do most of this:
Bob
OK - so if they are already logged in then - presumably - you have their user id tied to the registration ??? (If not then I'd suggest that you add it).
There are several ways to do this. The simplest is probably to use three forms. The first form will only have an on-load section and will:
a) Check their User ID and look up their registration
b) Redirect them to another form depending on whether the registration is found or not
One Custom Code action like this will do most of this:
<?php
$user =& JFactory::get User();
$app =& JFactory::getApplication();
$db =& JFactory::getDBO();
$query = "
SELECT COUNT(*)
FROM `#__some_table`
WHERE `user_id` = '{$user->id}' ;
";
$db->setQuery($query);
$count = $db->loadResult();
$uri = JURI::root().'index.php?option=com_chronoforms&chronoform=';
if ( $count >= 1 ) {
$app->redirect($uri.'form_2_name');
} else {
$app->redirect($uri.'form_3_name');
}
?>!! Not tested and may need debugging.
Bob
Thanks Bob,
The users information (id, etc) is being pulled into hidden fields in both forms. Theres only some text and a submit button for each of them. I'm using the chronoforms module for each of my forms, so how would I load one form over the other versus redirecting to a url? If there are 3 forms could form A load B or C based on a value in the database? Or would I combine my 2 forms into one?
Heres the code block of each form
Register
Login
The users information (id, etc) is being pulled into hidden fields in both forms. Theres only some text and a submit button for each of them. I'm using the chronoforms module for each of my forms, so how would I load one form over the other versus redirecting to a url? If there are 3 forms could form A load B or C based on a value in the database? Or would I combine my 2 forms into one?
Heres the code block of each form
Register
<?php
global $mainframe;
$database =& JFactory::getDBO();
$my = JFactory::getUser();
$query = "SELECT *"
. "\n FROM #__comprofiler"
. "\n WHERE user_id = '$my->id'";
$database->setQuery( $query );
$cb = $database->loadObjectList();
$cb = $cb[0];
?><input id="ClientID" type="hidden" value="xxxxxxxx" name="ClientID" />
<input id="ProductCode" type="hidden" value="xxxxxxxx" name="ProductCode" />
<input id="ClientMemberID" type="hidden" value="{cfu_id}" name="ClientMemberID" />
<input id="Email" type="hidden" value="{cfu_email}" name="Email" />
<input id="FirstName" type="hidden" value="<?php echo $cb->firstname; ?>" name="FirstName" />
<input id="LastName" type="hidden" value="<?php echo $cb->lastname; ?>" name="LastName" />
<input id="Address" type="hidden" value="<?php echo $cb->cb_address; ?>" name="Address" />
<input id="City" type="hidden" value="<?php echo $cb->cb_city; ?>" name="City" />
<input id="State" type="hidden" value="<?php echo $cb->cb_state; ?>" name="State" />
<input id="Zipcode" type="hidden" value="<?php echo $cb->cb_zipcode; ?>" name="Zipcode" />
<input id="Phone" type="hidden" value="<?php echo $cb->cb_phone; ?>" name="Phone" />
<div class="ccms_form_element cfdiv_submit" id="input_submit_131_container_div" style="text-align:left"><input name="input_submit_13" class="" value="Enroll" type="submit" />
<div class="clear"></div><div id="error-message-input_submit_13"></div></div><div class="ccms_form_element cfdiv_custom" id="input_id_26_container_div" style=""><div class="ccms_form_element cfdiv_submit" style="text-align:left"><a href="index.php?option=com_k2&view=item&layout=item&id=375&Itemid=1136">Add A member</a>
</div><div class="clear"></div><div id="error-message-Add A member"></div></div><div class="ccms_form_element cfdiv_empty" id="empty_container_div" style=""><div class="clear"></div><div id="error-message-empty"></div></div>
Login
<?php
global $mainframe;
$database =& JFactory::getDBO();
$my = JFactory::getUser();
$query = "SELECT *"
. "\n FROM #__comprofiler"
. "\n WHERE user_id = '$my->id'";
$database->setQuery( $query );
$cb = $database->loadObjectList();
$cb = $cb[0];
?><input id="ClientID" type="hidden" value="1052616" name="ClientID" />
<input id="ClientMemberID" type="hidden" value="{cfu_id}" name="ClientMemberID" />
<input id="MembershipID" type="hidden" value="<?php echo $cb->cb_creditmonitoring; ?>" name="MembershipID" />
<div class="ccms_form_element cfdiv_custom" id="body_text_container_div" style=""><p><img style="vertical-align: middle;" alt="creditmonitoring" src="images/creditmonitoring.jpg" height="216" width="200" />
</p>
<p>Some Text goes here.</p><div class="clear"></div><div id="error-message-Body Text"></div></div><div class="ccms_form_element cfdiv_submit" id="input_submit_131_container_div" style="text-align:left"><input name="input_submit_13" class="" value="Access Now" type="submit" />
<div class="clear"></div><div id="error-message-input_submit_13"></div></div><div class="ccms_form_element cfdiv_custom" id="input_id_20_container_div" style=""><p>Your Member ID: <?php echo $cb->cb_creditmonitoring; ?></p><div class="clear"></div><div id="error-message-input_custom_20"></div></div><div class="ccms_form_element cfdiv_empty" id="empty_container_div" style=""><div class="clear"></div><div id="error-message-empty"></div></div>
Hi dksf,
I'm not sure how you would do it and stay in a module. Maybe using Ajax and JavaScript?? Or you could use an modal window and an iFrame . . . or, having said that, maybe an iFrame in a window.
Bob
I'm not sure how you would do it and stay in a module. Maybe using Ajax and JavaScript?? Or you could use an modal window and an iFrame . . . or, having said that, maybe an iFrame in a window.
Bob
Hi Bob,
Maybe I'm over thinking this. Isn't it possible to have more than one submit button in a form that would be based on an event?
My forms are prefilled with the users information and both use the same fields. If I use one form with events that are triggered by a field value couldn't I show a submit button in the event? So something like event A - field1 = "NULL" then show submit button that processes the data for registration. Event B - field1 = "member_number" then show submit button that processes the data for login. I came across this post which seems to do this - http://www.chronoengine.com/forums/posts/f5/t94462.html
Maybe I'm over thinking this. Isn't it possible to have more than one submit button in a form that would be based on an event?
My forms are prefilled with the users information and both use the same fields. If I use one form with events that are triggered by a field value couldn't I show a submit button in the event? So something like event A - field1 = "NULL" then show submit button that processes the data for registration. Event B - field1 = "member_number" then show submit button that processes the data for login. I came across this post which seems to do this - http://www.chronoengine.com/forums/posts/f5/t94462.html
Hi dksf,
You can certainly use two submit buttons or a radio button plus a single submit button
BUT . . . thinking about it, if you already know if they are registered or not you can do the selection in the form On Load event and just show them the appropriate button. Would that work?
Bob
You can certainly use two submit buttons or a radio button plus a single submit button
BUT . . . thinking about it, if you already know if they are registered or not you can do the selection in the form On Load event and just show them the appropriate button. Would that work?
Bob
Hi Bob,
That would totally work. So on Load would check a table entry and then display the appropriate submit button? I'm using curl to process my forms so I have 2 different files. is it possible to add the code to process the form in chronoforms as an action? Seems I need to do this as I send out an email with one of the forms - which doesn't work with curl.
That would totally work. So on Load would check a table entry and then display the appropriate submit button? I'm using curl to process my forms so I have 2 different files. is it possible to add the code to process the form in chronoforms as an action? Seems I need to do this as I send out an email with one of the forms - which doesn't work with curl.
Hi dksf,
You can use the ChronoForms cURL action (or two of them) with the Event Switcher. Or you can include different PHP files into a Custom code action depending on the values:
Bob
You can use the ChronoForms cURL action (or two of them) with the Event Switcher. Or you can include different PHP files into a Custom code action depending on the values:
<?php
if ( $form->data['xxx'] == 'a' ) {
include (JPATH_SITE.'/components/com_chronoforms/includes/form_a.php');
} else {
include (JPATH_SITE.'/components/com_chronoforms/includes/form_b.php');
}
?>
Bob
Thanks Bob,
Adding the custom code to my onsubmit event kind of works. The data from my field doesn't seem to be getting checked first though. Regardless of whats in the field data formb.php gets loaded and runs.
The next event in my submit is an email action which I'd only need to trigger is forma.php is loaded. Thats why I thought using your events action would have played a part.
Adding the custom code to my onsubmit event kind of works. The data from my field doesn't seem to be getting checked first though. Regardless of whats in the field data formb.php gets loaded and runs.
The next event in my submit is an email action which I'd only need to trigger is forma.php is loaded. Thats why I thought using your events action would have played a part.
Hi dksf,
The code looks good (though there's always the possibility of a typo) so if it isn't working add a Debugger or two to see exactly what is happening.
Bob
The code looks good (though there's always the possibility of a typo) so if it isn't working add a Debugger or two to see exactly what is happening.
Bob
Hi Bob,
Doesn't appear to be any typo's - I double checked. And I don't see anything amiss in the debugger. In the array the form data is showing as [cb_credstatus] => OFF
Heres what I have on my forms On Submit
1. Load User Info [GH]
2. Auto JavaScript Validation
3. Data To Session
4. Curl - with no Target URL but all form fields are mapped
5. Custom Code - Process form data
6. Email - Welcome Email - only needs to be sent out if createaccount.php is used
7. Debugger
Doesn't appear to be any typo's - I double checked. And I don't see anything amiss in the debugger. In the array the form data is showing as [cb_credstatus] => OFF
Heres what I have on my forms On Submit
1. Load User Info [GH]
2. Auto JavaScript Validation
3. Data To Session
4. Curl - with no Target URL but all form fields are mapped
5. Custom Code - Process form data
<?php
if ( $form->data['cb_credstatus'] == 'OFF' ) {
include (JPATH_SITE.'/folder/createaccount.php');
} else {
include (JPATH_SITE.'/folder/signon.php');
}
?>
6. Email - Welcome Email - only needs to be sent out if createaccount.php is used
7. Debugger
This topic is locked and no more replies can be posted.
