I'm trying to prevent a user from being saved with Rules when he/she tries to use a username that contains a whitespace. I've already read How can I disallow spaces in usernames? and used the User restrictions module to achieve this, but I'd like to use Rules to do some other stuff (e.g. checking that the username doesn't have more than 20 characters).
So, what I'd like to do is showing an error message on the page and keep all the filled in information in the form without saving it. Is it possible to do this?
This is the Rule I'm currently using:
- Event: Before saving a user account.
- Conditions: NOT Execute custom PHP code.
<?php preg_match('/\s/',$account->name) == 1; ?>
- Actions: Show a message on the site.