• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Registration Plug In - 2nd time registering fails

Registration Plug In - 2nd time registering fails 12 years 4 months ago #20347

I've poked around to see if anyone else had this problem and couldn't find much. I found people with similar problems - but not the same. Anyway here is the description of the problem and the fix I implemented:

I'm using the registration plug in. I have a scholarship application where on the first screen the user enters an email and a password (both twice to make sure they get it right). I'm using the email as the username. They then proceed with the application. Once they submit, the form is submitted perfectly and their registration is created. However if they then go and apply for another scholarship (there are two types) and the same thing is done the first screen validation fails because a user already exists with that username. The failure messsage was vague as well.

So I hacked the registration plug in code to ignore the registration process if the user is already registered. The details:

- modify regValidateEmail to not check for duplicates. Instead if the email is not blank and passes the other email validation in that function just return true.
- modify refValidateUsername the same way.
- I added a proc that given a username returns if that user is already registered:
function regUsernameExists($username)
	{
		// added by R.J. Edgar
		$db =& JFactory::getDBO();
		$db->setQuery("SELECT id FROM #__users WHERE `username` LIKE '".$db->getEscaped($username)."'");
		return $db->loadResult() ? true : false;
	}

added code to beginning of register16 function that returns if that user already exists. I put it after the lant->load statement, but I think it could have gone first:
if (plgSystemRSFPRegistration::regUsernameExists($vars['username'])) {
			// user already registered.
			return true;
		}

Its not a perfect fix. If you are not using the email as the username you may want to add code that checks for the email already being in use. I'm not sure what you would do though if the username didn't exist but the email address did?

So far my testing shows this to do what I want.

I started down the path of if the user was registered of having the code update the password - then realized that would be a big security hole.

Is there an easier solution? I guess one solution would be to separate the user registration from the form process, but doesn't that defeat the whole idea for the registration plugin? Somehow I get the feeling that I'm missing something because this seems like it would be a common problem?
The administrator has disabled public write access.

Registration Plug In - 2nd time registering fails 12 years 3 months ago #20889

So my solution ran into a problem. It worked perfectly if their user account was created via rsform. However if they first created an account and did not choose the email address to be the same as the username the code got confused thinking they were not registered (since I was only checking the username). So I added another proc:
function regEmailExists($value)
	{
		// added by R.J. Edgar
		$db =& JFactory::getDBO();
		$db->setQuery("SELECT id FROM #__users WHERE `email` LIKE '".$db->getEscaped($value)."'");
		return $db->loadResult() ? true : false;
	}

Then if the regUserNameExists passed (i.e. user was not registered) I added an:
else if (plgSystemRSFPRegistration::regEmailExists($vars['email']) {
	// user already registered with this email. 
	// do nothing
	return true;
}

This way if the username or the email address is used it won't attempt to reregister.

This code is in plugins/system/rsfpregistration/rsfpregistration.php

I don't recommend changing this unless you understand everything I did above.
Last Edit: 12 years 3 months ago by richedgar.
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!