Stopping Registration at the door...


Well-known member
So I wrote a StopForumSpam function on my XenUtiles release...

class EWRutiles_ControllerPublic_Register extends XFCP_EWRutiles_ControllerPublic_Register
	public function actionRegister()
		$response = parent::actionRegister();
		$options = XenForo_Application::get('options');

		$data = $this->_input->filter(array(
			'username'   => XenForo_Input::STRING,
			'email'      => XenForo_Input::STRING,
		$data['ip'] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : false;

		$errors = $this->getModelFromCache('EWRutiles_Model_ForumSpam')->checkDatabase($data, $count);

        if ($count >= $options->EWRutiles_forumspam_hound)
            return $this->_getRegisterFormResponse($data, $errors);

		return $response;
Looks simple right? It checks against errors, and if the number of errors exceed the error requirement for the StopForumSpam check, it returns the errors back to the parent. This works. If the error requirement is met, it is properly displays the errors such as "Your username was found on the StopForumSpam database and has been rejected."

However, the problem is that even though the error is presented to the user, it still registers their account. I just tested it on my forums by registering with known spammer usernames and emails; it did properly give me StopForumSpam errors, but as long as I filled in all the rest of the required information, it still registered my account and presented "Your account is currently awaiting confirmation." on top of the registration form.

How do I fix this?


You're calling as first
$response = parent::actionRegister();
so it's creating the users, and then you're making the check:D

strange logic^^


Well-known member
Yeah, well before XenForo I have had ZERO experience with object oriented programming. I am learned in Perl, C++ and other procedural languages. And except for the DataWriters in VB4 (I wouldn't be surprised if the DW system was one of the few things Kier/Mike wrote before they left Jelsoft), everything there was procedural as well.

Still, I don't think I'm doing so bad...