Welcome Guest, Not a member yet? Register   Sign In
TankAuth: Checking user age as a callback function
#1

[eluser]Unknown[/eluser]
I have added date of birth to the registration process for tankauth. The way I did it was 3 fields dob1, dob2, dob3 (mm,dd,yyyy). What I want now is to use a callback function to check to see if the user is 13 years or older before they can register. This is what I have attempted so far:

NOTE: This is how I implemented the date of birth if it helps/ if anyone wants to know:
http://stackoverflow.com/questions/12379...rth-issues

inside the register() function:
Code:
$this->form_validation->set_rules('dob1', 'Date of Birth Month', 'trim|required|xss_clean|exact_length[2]');
$this->form_validation->set_rules('dob2', 'Date of Birth Day', 'trim|required|xss_clean|exact_length[2]');
$this->form_validation->set_rules('dob3', 'Date of Birth Year', 'trim|required|xss_clean|exact_length[4]|callback_is_old_enough[dob1||dob2]');

and this is my callback funtion:
Code:
//Check if user is old enough
function is_old_enough($input, $dob1, $dob2) {
      $dob = $dob1.$dob2.$input;
      $date = strtotime('-13 years');
      $dateCheck = date('mdY', $date);
      if ((int)$dob < (int)$dateCheck)
          $this->form_validation->set_message('is_old_enough', 'You are not old enough to register on this site.');
      return $input;
}

Right now it acts as if the callback is not even there. Any help?


Messages In This Thread
TankAuth: Checking user age as a callback function - by El Forum - 09-14-2012, 12:40 PM
TankAuth: Checking user age as a callback function - by El Forum - 09-14-2012, 02:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB