Question

How do I use the form API to make a field that only accepts names of registered users? I know how to do the autocomplete to suggest user names already.

Specifically, I'm looking to replicate the field in the normal node creation process that allows the user to specify an author.

Was it helpful?

Solution

The user module doesn't have a user list function, but a simple database query will get you that. Then in the form_validate function, you can check that the entered name really is a valid user with user_authenticate.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top