Skip Navigation

[Closed] limiting submittals based on a field in another post type

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 1 year, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#2576957

Tell us what you are trying to do?

I have users for which I have a "buyer profile" post type set up for each.
Users WILL NOT be able to create their own accounts - An administrator will create a user account and then set up an associated Buyer Account.

Buyers are allowed to put up RFPs, which I have set up as another post type.

Each buyer can submit RFPs only for specific countries.
Initially, I had it set up using a taxonomy of the countries, and that same taxonomy is associated with both the "buyer profile" post type and the "RFP" post type.

My thought was to choose the countries for which the buyer can submit RFPs in their "buyer profile" and then somehow either validate that the user has chosen only the countries allowed in the RFP post type post form, or only show the ones that they can submit to in the form.

It looks like this may not be possible using a taxonomy - it seems as though showing/hiding a taxonomy is an all-or-nothing proposition.

So I'm thinking about changing over to using a checkbox field - or perhaps I need an individual field for each country?

I'm stuck on how I either (1) show only the countries they are authorized to submit for as the options on the RFP post form or (2) validate on submittal of the RFP that they only chose the countries they are authorized for.

Is there any documentation that you are following?

I've dug around a bit, but haven't found anything that seems to match - here are a few:
https://toolset.com/forums/topic/display-field-conditionally-in-relationship-form-using-select-option/
https://toolset.com/forums/topic/using-conditionals-in-forms/

Both of these seem more about basing conditions upon what is chosen on the form as opposed to a field from another post.

Is there a similar example that we can see?

Not that I know of.

What is the link to your site?

ipasprocurestg.wpengine.com

#2577457

Hello,

There isn't such kind of built-in feature within Toolset plugins, it needs custom codes.

When user create new "RFPs" post, how much countries can connect with the new "RFPs" post? one or multiple countries?
I need to check if there is other workaround for your case.

#2577715

Thanks! Multiple countries.

#2578179

It is possible with custom codes, for example, when you display the post form with country taxonomy field, you can use WP built-in filter hook "get_terms" to trigger a custom PHP function:
https://developer.wordpress.org/reference/hooks/get_terms/

In this PHP function, get the current logged-in user's ID:
https://developer.wordpress.org/reference/functions/get_current_user_id/
Get the "buyer profile" post ID by above user ID
https://developer.wordpress.org/reference/functions/get_posts/
Get the country terms by above "buyer profile" post ID
https://developer.wordpress.org/reference/functions/wp_get_object_terms/
and return above terms

Please let me know if you need assistance to setup the custom codes.

The topic ‘[Closed] limiting submittals based on a field in another post type’ is closed to new replies.