Is user already registered?

driv 20 Aug, 2016
When using Chronoforms to sign up for an event, is it possible to inform the user that they have already registered - by checking if the email address is already in the database?
(Ideally, by checking their email address against a specific year and not allowing them to submit the form.)

Thanks.πŸ™‚
driv 20 Aug, 2016
By the way... The user would not be a member (or logged into) the Joomla site if that's relevant.
GreyHead 21 Aug, 2016
1 Likes
Hi driv,

Yes, use an Event Switcher action in the On Submit event to run a query to check your database records. Have one event set called say 'already_registered' and set a message and Show Stopper action in that. The code will be something like this
<?php
$db =& JFactory::getDBO();
$year = date('Y');
$query = "
    SELECT COUNT(*)
        FROM `#__some_table`
        WHERE `email` = '{$form->data['email']}' && `year` =  '{$year}';
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count > 0 ) {
  return 'already_registered';
}
?>

Bob
driv 21 Aug, 2016
Hi Bob,
Good to know that this can be done.πŸ™‚ I've been experimenting today, but no luck so far.

I'm still quite inexperienced with Chronoforms, so I was wondering if this is how you envisaged things being done.
(Please see image.)
Looking at the php code, I'm thinking that the display message and show stopper should be in the 'on success' area.

Also,
Should #__Delegates be renamed completely with my table prefix (or does Chronoforms 'know' the prefix)?

Thanks,
d.
GreyHead 21 Aug, 2016
Hi driv,

Your Event Switcher still has success & fail as the events, I suggest that you replace those with the single already_registered event (simply because that makes the function clearer).

Joomla! will replace #__ with the default table prefix for your site.

Bob
driv 22 Aug, 2016
That was it Bob! Thanks very much.πŸ™‚

Is it possible to include any of these dbase details (e.g. name, email) in the 'Display Message' action?
GreyHead 22 Aug, 2016
Hi driv,

You can add anything from the $form->data array into the Display Message action as e.g. {email} or {first_name}

Note: the Display Message action doesn't support PHP - if you need that for some reason use a Custom Code action instead.

Bob
driv 23 Aug, 2016

You can add anything from the $form->data array into the Display Message action as e.g. {email}


I wasn't aware of that, great news!

Note: the Display Message action doesn't support PHP - if you need that for some reason use a Custom Code action instead.


Also good to know. It seems you can do virtually everthing with Chronoforms.πŸ™‚

Thanks again Bob!
This topic is locked and no more replies can be posted.