Hi guys, I have a task that I can't accomplish or get my head around to on an old site
that is using the userreference widget in CCK.
The problem and what I want to happen
When using the autocomplete widget, a user types a name, many suggestions come up. The problem with this is that
I want to limit the number of suggestion based on what user-role the logged-in-user has.
Outline
There are two node-types (node-type-1 and node-type-2)
In node-type-1 I can add (as an admin) a list of users in the userreference field.
These users referenced together in the node-type-1 then can add nodes of node-type-2
where they have a userreference form item too and in that field they should be able to add ONLY users that are in store in the userreference field of node-type-1
What is the way to go?
- Do I alter the #view_callback directly via hook_form_alter?
-- What do I need to take in consideration here when I do that?
- Defining a new widget might be a problem since I have to consider the data that is already in store.
-- (an idea that I need feedback on if defining a new widget would be the case) If defining a new widget, would adding hook_update help just update the schema and keep data stored of the previous widget?
This is a bit of a scary problem, since listing ALL users is not always the best idea.
I was really hoping for a hook_widget_alter or similar approach. What I've come up with so far is altering the #value_callback of the form item but I'm not sure if this is really the way to go. As you might already see for yourself here is that using views to display the list of users here doesn't cut it.
I hope I made my problem pretty clear as I tried to thorough.