07-02-2008, 10:12 AM
[eluser]Bramme[/eluser]
These are the rules of my profile editting form (not much profile info, just a name, email, login name and optional password changing).
Using these rules, the password changing is not required, but if they are set, they do get validated...
If you're interested in my custom callback method:
These are the rules of my profile editting form (not much profile info, just a name, email, login name and optional password changing).
Code:
$rules['name'] = 'required';
$rules['login'] = 'required';
$rules['email'] = 'required|valid_email';
$rules['curr_pw'] = 'callback_matches_curr_pw';
$rules['new_pw'] = 'matches[new_pw_check]';
Using these rules, the password changing is not required, but if they are set, they do get validated...
If you're interested in my custom callback method:
Code:
function matches_curr_pw($str) {
if(empty($str)) {
return true;
} else {
$curr_pw = md5($str);
$this->db->where('ID', $this->session->userdata('user_id'));
$qry = $this->db->get('users');
$row = $qry->row_array();
$db_pw = $row['paswoord'];
if($curr_pw == $db_pw) {
return true;
} else {
$this->validation->set_message('matches_curr_pw', 'Het %s veld komt niet overeen met het paswoord in de database.');
return false;
}
}
}