Users have access to add Commerce Products into the Store and publish it. How to display to user only allowed firms in the product addition form? My webshop has lot of users with role Seller. They can add SKU and publish goods. Product display content type has field "Firm" that is taxonomy term reference.

Now every Seller can see all the firms (all the terms) when he add a product and he can check anyone. This is very uncomfortable because Seller work with only a few firms and he want to see only his firms to check one of it.

I want to display only user referenced firms in this field when user add a product.

How do I do this?


I've added to user profile field "Seller Firms" that is the term reference to the Firms. Using module Field Permissions I've made this field accessible to edit only by administrator.
I've checked for each user his firms that he can have access to publish goods of these firms (seller will can to check only those firms that I've checked in profile)
So how to alter product addition form to show only user allowed firms? I have few product displays machine names: product, product_with_attributes


I think this will be hook_alter_form or Rule that will limit the selection to only a few firms that are allowed.

I've made the first part this way:
1. I add Entity Reference field "Seller" to taxonomy Firms that link to users profiles. 
2. I'd fill this field for all terms with users that must have access 
3. I start to write my module that will display only user referenced terms in node add form. I do not know how to write this. The field name in node Product Display: field_firm. Field Entity Reference in terms: field_seller. Help me to finish my module:  

function user_referenced_taxonomy_terms_form_node_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  //$form ['field_firm']
}
It is possible using hook_alter_form but hook_form_FORM_ID_alter would be better so you only target the correct form.

You will need code to retrieve only the firms the user has from their profile field and then using array_diff to remove the others from the select options.