wp-cli/wp-cli — pull request #889 by leewillis77 (2013-11-26 07:41:18+00:00)
Title: Dont' ignore --role when creating users

Currently the following command results in a user being created with the default site role, rather than the role being passed in.

```
wp user create user email@example.com --role=author
```

The failure happens because the code calls validate_role() and expects a valid role to be returned: https://github.com/leewillis77/wp-cli/blob/master/php/commands/user.php#L196

Currently validate_role returns false where no role is passed in, but doesn't have an explicit return value for the case where a role is passed in, but is invalid, or if it's valid.

This change makes validate_role return either false if the role is invalid (In which case a user will be created with the site's default role) - or the role string if it is valid.

After this change the initial command works as expected.

An alternative approach would be to make validate_role() return strictly boolean true or false, and adjust the role appropriately at the calling sites (create() and generate()). Happy to update to that if you'd prefer.