Skip Navigation

[Resolved] Display custom field value based on selection of a post reference field

This support ticket is created 6 years ago. There's a good chance that you are reading advice that it now obsolete.

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/Karachi (GMT+05:00)

This topic contains 3 replies, has 2 voices.

Last updated by Waqar 6 years ago.

Assisted by: Waqar.

Author
Posts
#1175789

Tell us what you are trying to do?

I have a CPT Attorneys. I also have a Custom Field Group for the Attorneys CPT. One of the fields is a Flag (dropdown) that is set when admin creates an Attorney.

I also have another CPT called Referrals. I have a CRED Post form for the Referral CPT where I've added the Attorney post reference field (which is a JQUERY dropdown ).

What I would like to do is when a user Selects an Attorney on the CRED Post FOrm, I want to display the Flag field value set for that Attorney on the CRED Post Form.

What would be the best way to do this?
Is there any documentation that you are following?
None.

Is there a similar example that we can see?
I've search the Support site but could not find a similar post.
What is the link to your site?
hidden link

#1175917

Hi Mukesh,

Thank you for contacting us and I'd be happy to assist.

I'm afraid, there is no direct feature available in Toolset plugins, to achieve what you're planning.

You'll need a custom AJAX call function on the page with the cred form, which will trigger when the value of the attorney's post reference field changes. Using the ID of the selected attorney, you can fetch any custom field value connected to that attorney's CPT and show it at the desired HTML element.

Following are some useful guides on using AJAX in WordPress environment:
https://codex.wordpress.org/AJAX_in_Plugins
hidden link
hidden link
hidden link

I hope this helps!

regards,
Waqar

#1176742

Thanks Waqar. Yes I figured that there will not be any built-in feature and will require custom coding. Are there any endpoint URLs provided by Toolset plugins that I can call via AJAX to make the calls or the WordPress REST API would work? Any other samples from other support topics you can direct me towards?

Thanks again,
Mukesh

#1176873

Hi Mukesh,

Thanks for writing back.

I'm afraid, I don't have any example to share from our support forum, but the links from my last message should help you get started in the right direction.

When using AJAX in WordPress environment, all calls are made to the "admin-ajax.php" file in the "wp-admin" folder. You won't need to use WordPress REST API endpoints in this case. Though if you prefer to use WordPress REST API, you can use it as an alternative approach.
( https://developer.wordpress.org/rest-api/ )

For more personalized and in-depth assistance around custom programming, you can also consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

regards,
Waqar