Check email in user table - registration

momentis 26 Apr, 2012
I have a CF form that, among other things, creates a new user in the Joomla users table. I am using the Joomla user registration plugin in CF.

I found a few other posts in the forums related to this issue, but I cannot get it to work. In the On Submit event, I have a Custom Server Side Validation action which contains the following code:

    <?php
    $checkmail = $form->data['acct_user_id'];
    $db =& JFactory::getDBO();
    $query = "
        SELECT COUNT(`email`)
            FROM `#__users`
            WHERE `email` = '$checkmail' ;
    ";
    $db->setQuery($query);
    $count = $db->loadResult();
    if ( $count ) {
      $mainframe =& JFactory::getApplication();
      $mainframe->enqueuemessage('This account has already been registered.');
      return false;
    }
    ?>


In the OnFail section, I put a ShowStopper action. This is not working for me. With debugging turned on, I can see where Joomla is returning that the email already exists. I have no idea how to stop the form submission if the email already exists.
GreyHead 26 Apr, 2012
Hi Rick,

What do you want to have happen here? Usually the Joomla! Registration plug-in will flag the error if the email or Username are in use.

You may need to use an Event Loop to redisplay the form rather than a Show Stopper to kill the process completely.

Bob
momentis 26 Apr, 2012
I do want the form to redisplay so that the email address can be changed (along with displaying some sort of error message). As it stands now, the form just goes ahead and emails the user login credentials, but the user is, of course, not actually added to the "#__users" table. Upon submitting, the form is also populating another table in the database. I don't want any of this to happen if the email exists.
GreyHead 27 Apr, 2012
Hi Rick,

There are two possibilities I see.

First, you could check this in the form using Ajax. That would do the check before the form is submitted.

Second, you could use a Custom Serverside Validation action near the start of the On Submit action to run the check and re-load the form with an Event Loop action if the check fails.

Bob
momentis 27 Apr, 2012
Yeah, I tried to do the second one you mention with the code in my first post. I guess I just need to play around more, because I can't get it to work. And I guess I better understand the Event Loop action better!! 🙂
This topic is locked and no more replies can be posted.