[eluser]CroNiX[/eluser]
The first parameter passed to a validation callback function is always the VALUE that that form control sent. In this case the value of the email field, which will not be a boolean FALSE. So $only_identity can't be FALSE which is why this isn't working.
You can only manually pass a parameter to the callback function if you use the square brackets and pass it in there, which will be sent as the 2nd parameter to your callback. This is always a string.
Send the string 'false' as a 2nd parameter to the callback function:
Code:
$this->form_validation->set_rules('email', 'Email', 'trim|required|callback__validate_credentials[false]|valid_email|xss_clean');
Receive the 2nd parameter in the callback function:
Code:
function _validate_credentials($field_value, $only_identity='true')
{
if ($only_identity == 'false')
{
//the parameter was set and it was false
}
else
{
//the parameter was not set, so it must be true
}
And to use the same callback without sending the 2nd parameter, just remove the brackets, and $only_identity will be considered 'true':
Code:
$this->form_validation->set_rules('email', 'Email', 'trim|required|callback__validate_credentials|valid_email|xss_clean');