Hi there,
I try to prevent that new Users can use blanks in their username.
(and btw I think its a bug that the addon can create users with that)
It should be “JaneDoe” or “jane-doe” but NOT “Jane Doe”
I already tried this code which I found in this code here in the forum:
// form 14, field 3
add_filter( 'gform_field_validation_14_3', 'character_validation', 10, 4 );
function character_validation( $result, $value, $form, $field ) {
// combine all three parts of the name field into one string for easy comparison
$all_names = implode( $value );
GFCommon::log_debug( __METHOD__ . '(): ALL NAMES => ' . print_r( $all_names, true ) );
// Check if value contains only letters (A-Z and a-z)
if ( ! preg_match( '/^[A-Za-z\-]+$/', $all_names ) ) {
$result['is_valid'] = false;
$result['message'] = 'Bitte nur Buchstaben, Zahlen und Bindestrich verwenden. Keine Leerzeichen verlaubt.';
}
return $result;
}
But that caused an php error
Any other ideas?