-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unique username and unique email validators to custom validatio…
…n library, so they actually run...
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | ||
|
||
class MY_Form_validation extends CI_Form_validation { | ||
public function __construct() { | ||
parent::__construct(); | ||
|
||
$this->CI =& get_instance(); | ||
} | ||
|
||
function unique_email($email) { | ||
$this->CI->load->model('users/user_model'); | ||
if ($this->CI->user_model->unique_email($email)) { | ||
return TRUE; | ||
} | ||
else { | ||
$this->CI->form_validation->set_message('unique_email', 'The Email you have selected is unavailable.'); | ||
return FALSE; | ||
} | ||
} | ||
|
||
function unique_username($username) { | ||
$this->CI->load->model('users/user_model'); | ||
if ($this->CI->user_model->unique_username($username)) { | ||
return TRUE; | ||
} | ||
else { | ||
$this->CI->form_validation->set_message('unique_username', 'The Username you have selected is unavailable.'); | ||
return FALSE; | ||
} | ||
} | ||
} |