Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ericlbarnes
Created July 5, 2010 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericlbarnes/464321 to your computer and use it in GitHub Desktop.
Save ericlbarnes/464321 to your computer and use it in GitHub Desktop.
// ------------------------------------------------------------------------
/**
* 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