• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

How to add custom input filter to extended class?

#1
I want to add a custom input filter to actionRegister() function

This is my code:

PHP:
    protected function _getRegisterFormResponse(array $fields, array $errors = array())
    {
        $response = parent::_getRegisterFormResponse($fields, $errors);
        $response->params += array('data' => $fields);
        return $response;
    }
    public function actionRegister()
    {
        $response = parent::actionRegister();
 
        $data = $this->_input->filter(array(
            'emailconfirm_key'  => XenForo_Input::STRING,
        ));
       
        $response->params['fields'] += $data;
        $response->params['data'] += $data;
        return $response;
    }
This didn't work, only work when I add the custom input filter manually to the default xenforo actionRegister() function.

Any help is appreciated.
 
#2
lol, I fixed the issue :)

This is working:

PHP:
    public function actionRegister()
    {
        $response = parent::actionRegister();
 
        $errors = array();
        $data = $this->_input->filter(array(
            'emailconfirm_key'  => XenForo_Input::STRING,
        ));
       
        $writer = XenForo_DataWriter::create('XenForo_DataWriter_User');
        $writer->bulkSet($data);
       
        $errors = array_merge($errors, $writer->getErrors());
        if ($errors)
        {
            $response->params['fields'] += $data;
            $response->params['errors'] += $errors;
            return $this->_getRegisterFormResponse($response->params['fields'], $response->params['errors']);
        }
       
        return $response;
    }