User attributes are a convenient way to vary shading across multiple objects without changing a shading network. They are especially useful as they can vary across instances, unlike primitive variables.
Setting User Attributes
Here is an example of how to set a color user attribute with an OpScript:
...