Welcome Guest, Not a member yet? Register   Sign In
Backend Pro for codeigniter 2
#20

[eluser]shinokada[/eluser]
I tried this but it did not work. So I came up a temporary solution, but there must be a better way to solve this.


1. In modules/auth/language/english/uerlib_lang.php, add these.


Code:
$lang['userlib_email_used'] = 'The email provided is used.';
$lang['userlib_username_used'] = 'The username provided is used.';

2. In modules/auth/libraries/Auth_form_prcessing, swap function register_form($container) to the following.

Code:
/**
  * Register form
  *
  * Display the register form to the user
  *
  * @access public
  * @param string $container View file container
  */
function register_form($container)
{
  if( ! $this->CI->preference->item('allow_user_registration'))
  {
   // If registration is not allowed
   flashMsg('info',$this->CI->lang->line('userlib_registration_denied'));
   redirect('auth/login','location');
  }

  // Setup fields
  $fields['username'] = $this->CI->lang->line('userlib_username');
  $fields['password'] = $this->CI->lang->line('userlib_password');
  $fields['confirm_password'] = $this->CI->lang->line('userlib_confirm_password');
  $fields['email'] = $this->CI->lang->line('userlib_email');
  $fields['recaptcha_response_field'] = $this->CI->lang->line('userlib_captcha');
  $this->CI->form_validation->set_fields($fields);

  // Set Rules
  $config = array(
      array(
              'field'=>'username',
              'label'=>$this->CI->lang->line('userlib_username'),
              'rules'=>"trim|required|max_length[32]|callback_spare_username"
              ),
      array(
              'field'=>'email',
              'label'=>$this->CI->lang->line('userlib_email'),
              'rules'=>"trim|required|max_length[254]|valid_email|callback_spare_email"
              ),
      array(
              'field'=>'password',
              'label'=>$this->CI->lang->line('userlib_password'),
              'rules'=>"trim|required|min_length[".$this->CI->preference->item('min_password_length')."]|matches[confirm_password]"
              )
            );
  if($this->CI->preference->item('use_registration_captcha'))
  {
   $config = array(
       array(
                           'field'=>'recaptcha_response_field',
                           'label'=>$this->CI->lang->line('userlib_captcha'),
                           'rules'=>"trim|required|valid_captcha"
                           )
            );
  }
  $this->CI->form_validation->set_rules($config);

  if ( $this->CI->form_validation->run() == FALSE )
  {
   // Output any errors
   $this->CI->form_validation->output_errors();

   // Display page
   $data['header'] = $this->CI->lang->line('userlib_register');
   $data['captcha'] = ($this->CI->preference->item('use_registration_captcha')?$this->_generate_captcha():'');
   $data['page'] = $this->CI->config->item('backendpro_template_public') . 'form_register';
   $data['module'] = 'auth';
   $this->CI->load->view($container,$data);
  }
  else
  {
   // now CI validation is ok But...
   // since form_validation callback is not working I have to check
   // usename and email here
   $email     =$this->CI->input->post('email');
   $username  =$this->CI->input->post('username');
   if($this->CI->form_validation->spare_email($email))
   {
    // spare_email will return True when email is not used
    // now let's check username here
    if($this->CI->form_validation->spare_username($username))
    {
     // true means username is not used so redirect
     // everything is ok
     // Submit form
     $this->_register();
    }
    else
    {
     // this email exist so redirect with message
     flashMsg('error',$this->CI->lang->line('userlib_username_used'));
     redirect($this->CI->config->item('userlib_action_register'),'location');
    }
   }
   else
   {
    // this email exist so redirect with message
    flashMsg('error',$this->CI->lang->line('userlib_email_used'));
    redirect($this->CI->config->item('userlib_action_register'),'location');
   }
  }
}

3. And don't forget to change all the ->validation-> to ->form_validation-> in application/libraries/MY_Form_validation.



I hope this will help someone.


Messages In This Thread
Backend Pro for codeigniter 2 - by El Forum - 01-23-2012, 07:17 AM
Backend Pro for codeigniter 2 - by El Forum - 01-23-2012, 11:52 AM
Backend Pro for codeigniter 2 - by El Forum - 01-24-2012, 03:07 AM
Backend Pro for codeigniter 2 - by El Forum - 01-25-2012, 11:53 PM
Backend Pro for codeigniter 2 - by El Forum - 01-26-2012, 02:12 AM
Backend Pro for codeigniter 2 - by El Forum - 01-26-2012, 10:03 PM
Backend Pro for codeigniter 2 - by El Forum - 01-27-2012, 06:23 AM
Backend Pro for codeigniter 2 - by El Forum - 01-27-2012, 07:08 AM
Backend Pro for codeigniter 2 - by El Forum - 01-27-2012, 07:27 AM
Backend Pro for codeigniter 2 - by El Forum - 02-15-2012, 10:16 AM
Backend Pro for codeigniter 2 - by El Forum - 02-22-2012, 06:08 AM
Backend Pro for codeigniter 2 - by El Forum - 02-26-2012, 09:35 PM
Backend Pro for codeigniter 2 - by El Forum - 02-28-2012, 03:09 AM
Backend Pro for codeigniter 2 - by El Forum - 03-05-2012, 06:04 AM
Backend Pro for codeigniter 2 - by El Forum - 03-12-2012, 10:51 PM
Backend Pro for codeigniter 2 - by El Forum - 03-13-2012, 04:40 AM
Backend Pro for codeigniter 2 - by El Forum - 03-14-2012, 02:41 AM
Backend Pro for codeigniter 2 - by El Forum - 03-14-2012, 05:00 AM
Backend Pro for codeigniter 2 - by El Forum - 03-14-2012, 05:03 AM
Backend Pro for codeigniter 2 - by El Forum - 03-14-2012, 10:05 PM
Backend Pro for codeigniter 2 - by El Forum - 02-07-2013, 01:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB