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(&$form, &$form_state, $form_id) {
//$form ['field_firm']
}