Hi,
I created another topic for a specific problem with CRED Form, but it's just one problem inside a larger challenge.
I'm working a website where registered Users with a specific role (Access) can add Woocommerce products, but "framed products" depending on their relationships to the CPT "Type of Product".
The process to create a product related with CRED form :
- the author can specify some infos (custom fields) and choose a Type of Product, but won't be able to choose a price, a title and a stock,
- depending on the Type of Product he selected, the CRED Form uses parent informations to set price and stock, and uses custom fields to set the title.
That's my first problem I'm currently solving on another post.
Here's the larger challenge :
- I would like to set, individually per author, who can choose which CPT Type of Product,
- so when the author is on the CRED form, he can only choose the Type of Product he's assigned to.
In other words, it's kind of a many-to-many relationship between Users and CPT in order to restrict the choice. I read it's not possible that way, but they're old posts, maybe it changed. If not, these posts aren't clear enough for me, that's why I created this one.
Example :
- Author 1 is assigned to Type of Product A, C and D,
- Author 2 is assigned to Type of Product A, B and C,
- as admin, I set who is assigned to what ; a Type of Product can have different author and an author can have several Type of Product,
- when Author 1 arrives on the CRED Form to create a Woocommerce Product, he can only choose between A, C and D (because I assigned him to those),
- let say he selected C. Then when he creates the product through the CRED form, the CRED Form uses parent's informations (Type of Product), which is C, to add the price and the stock,
√ then the page of Type of Product C displays fields from the CPT such as description, title, images, price, etc,
√ and with a View, it displays all the children (Woocommerce product) with title of the products, author profile picture, author name.
I gave the 2 last lines to explain what's the final result, but this part is marked √ because it's done. My problem currently is the Author sees all the Type of Product choices on the CRED Form and I don't know how to assign the CPT to the User.
Of course it would much easier to just let the author have the choice among all the Type of Products, but my goal is to restrict that.
I'm open to any idea ton achieve that goal, as long as I can easily "assign" the authors to several Type of Product, because I hope I'll have many authors and many Type of Product.
Thanks for your help.