In buddypress I've added a field to profile named zip code
with type of number
.
What I need is to validate/cleanup this field before saving data into db, does buddypress support doing this? Is there any buddypress action/filter which let's run my custom validation for this field?
function myvalidator($retval, $field){
// $field->field_id <- from wp_bp_xprofile_fields table
// find id for your field
// $field->value <- this is the value you need to validate
// (make sure $field->field_id is correct
// $field->user_id
if (/* valid */){
return true;
} else {
return false;
}
// for other field_ids return $retval
}
add_filter( 'xprofile_data_is_valid_field', 'myvalidator', 10, 2 )