This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I'm building a contact list.
I have a CPT "Companies" and a "Contacts" with a relation One (Company) to Many (Contacts).
"Companies" have a CF "type of company" (producer, distributor, client)
I have another CPT "Product" with a relation One (company) to many (products)
I created a form to add a new product.
In that form I can add the related company to the product, but is there a way to being able to select only the Companies with the "type of company"="producer" ?
In your custom code, you can use either a custom query or a Toolset classic view to first get the list of 'Company' posts with a 'producer' value stored in the custom field and then pass those posts as options, through this filter.
I hope this helps and please let me know if you need further assistance.
Thanks for the infos.
Can you help me on how to make that limited list ? How should I format my simple View ? How can I integrate it to my custom code ?
To restart the explanation more adapted to my project. I have 2 CPT's : 'products' and 'companies'
The CPT 'companies' has a few custom fields. One of the field is called "company-status" and is a "Checkboxes" selection.
3 status (for the moment) in this selection : producer, licensor and distributor.
I define a 1 (Company) to Many (products) relationship that I called 'licensor-of-the-product'.
I created a form to add a new 'Product'. One of the form field is the relationship field 'licensor-of-the-product'.
This is where I need to only display the companies that have at least the 'licensor' option checked in its 'company-status' field.
This is the script I wrote but it still display all the companies:
Unfortunately when I create a new Product it still displays all the companies.
I'd like also this script working for a new Product or when Edit a Product.
I've performed some tests on my website and can confirm that the filter 'types_relationship_connect_existing_options' works for the relationship field on the post-edit screen in the admin area, but not for the front-end form.
For the front-end forms, you'll need to use a different workaround:
1. In your form to add a new product, you can replace the default relationship selection field for the 'company' with a 'select' type generic field.
2. This generic field will be set to populate the option through a custom shortcode, that will generate the options from the post type 'company' with necessary filtering, based on the custom field.
3. The last step would be to use a custom function attached to the 'cred_save_data' hook to connect the company post selected through the generic field with the newly created product post when the form is submitted.