Created
July 5, 2010 12:51
-
-
Save ericlbarnes/464321 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ------------------------------------------------------------------------ | |
/** | |
* Validate the username | |
* | |
* @access public | |
* @return string | |
*/ | |
public function username_check($username) | |
{ | |
if ($this->events->active_hook('users_controller/username_check')) | |
{ | |
return $this->events->trigger('users_controller/username_check', $username); | |
} | |
$this->db->select('user_username') | |
->from('users') | |
->where('user_username', $username); | |
$query = $this->db->get(); | |
if ($query->num_rows() > 0) | |
{ | |
$this->form_validation->set_message('username_check', lang('lang_username_in_use')); | |
return FALSE; | |
} | |
else | |
{ | |
return TRUE; | |
} | |
} | |
// EXAMPLE FROM EXTENSION FILE: | |
/** | |
* Setup form validation. | |
*/ | |
public function validation($username) | |
{ | |
// Do you vb username check: | |
$in_use = TRUE; | |
if ($in_use) | |
{ | |
$this->_ci->form_validation->set_message('username_check', lang('lang_username_in_use')); | |
return FALSE; | |
} | |
return TRUE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment