public static function clean_field($data, $field) {
        if (empty($data) || empty($field)) {
            return $data;
        }

        try {
            $type = core_user::get_property_type($field);

            if (isset(self::$propertiescache[$field]['choices'])) {
                if (!array_key_exists($data, self::$propertiescache[$field]['choices'])) {
                    if (isset(self::$propertiescache[$field]['default'])) {
                        $data = self::$propertiescache[$field]['default'];
                    } else {
                        $data = '';
                    }
                } else {
                    return $data;
                }
            } else {
                $data = clean_param($data, $type);
            }
        } catch (coding_exception $e) {
            debugging("The property '$field' could not be cleaned.", DEBUG_DEVELOPER);
        }

        return $data;
    }
public static function clean_field($data, $field) {
        if (empty($data) || empty($field)) {
            return $data;
        }

        try {
            $type = core_user::get_property_type($field);

            if (isset(self::$propertiescache[$field]['choices'])) {
                if (!array_key_exists($data, self::$propertiescache[$field]['choices'])) {
                    if (isset(self::$propertiescache[$field]['default'])) {
                        $data = self::$propertiescache[$field]['default'];
                    } else {
                        $data = '';
                    }
                } else {
                    return $data;
                }
            } else {
                $data = clean_param($data, $type);
            }
        } catch (coding_exception $e) {
            debugging("The property '$field' could not be cleaned.", DEBUG_DEVELOPER);
        }

        return $data;
    }
public static function clean_field ( $ data , $ field ) { if ( empty ( $ data ) || empty ( $ field ) ) { return $ data ; } try { $ type = core_user :: get_property_type ( $ field ) ; if ( isset ( self :: $ propertiescache [ $ field ] [ 'choices' ] ) ) { if ( ! array_key_exists ( $ data , self :: $ propertiescache [ $ field ] [ 'choices' ] ) ) { if ( isset ( self :: $ propertiescache [ $ field ] [ 'default' ] ) ) { $ data = self :: $ propertiescache [ $ field ] [ 'default' ] ; } else { $ data = '' ; } } else { return $ data ; } } else { $ data = clean_param ( $ data , $ type ) ; } } catch ( coding_exception $ e ) { debugging ( "The property '$field' could not be cleaned." , DEBUG_DEVELOPER ) ; } return $ data ; }
Clean a specific user field.

@param string $data the user field data to be cleaned.
@param string $field the user field name on the property definition cache.
@return string the cleaned user data.
Clean a specific user field .