Skip Navigation

[Resolved] Adding Several Custom Fields

This support ticket is created 4 years, 2 months 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)

Author
Posts
#1458271
relationships.png
custom-code-snippets.png
form-to-edit-a-provider-select-subspecialty.png
form-to-edit-a-provider-select-specialty.png
form-to-edit-a-provider-select-condition-treatment-2.png
form-to-edit-a-provider-select-condition-treatment-1.png
view-to-show-treatment-options-related-to-subspecialties.png
view-to-show-condition-options-related-to-subspecialties.png
view-to-show-subspecialties-options-related-to-a-specialties.png
view-to-show-current-providers-form.png

Thank you again for your help! We have two quick questions about the way you designed this -

1. How do we link the appropriate Specialty to Subspecialty, Conditions and Treatments?
For example: General Surgeon (Specialty) > Surgical Critical Care (Subspecialty) > Surgical Conditions treated > Surgical Treatments performed
Right now, we have all of the Specialty, Subspecialty, Conditions, and Treatments custom post types imported and created, but there is no specific connection established; just general relationships. We need to establish these in order for the form options to appear correctly. Do they have to be manually entered in somehow or put into our import CSV files?

2. Our Provider form only show some Specialty options/posts and not all of our Specialty posts/options. I have attached screenshots of our setup.

We appreciate all of your help! Thank you again, Waqar.

#1459685

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Glad those steps helped!

1. The link between posts can be created while they're being imported through the CSV file, as explained in this guide:
https://toolset.com/documentation/user-guides/export-import/importing-content-from-csv-with-post-relationships/

In summary, it is possible to save the title of the parent post in the relationship, as a special custom field value in the child post while importing and Toolset's relationship imported can then extract that info and create connections between those posts in bulk.

To avoid duplicates, you can delete the existing posts from these post types and then import them again, making sure that the column for neccessary relationships is also available in the child posts.

Note: In a relationship, the one on the left is a parent and the one on the right is a child.

Screenshot: hidden link

2. By default, the field to select the relationship item uses a special select field with an autocomplete feature.

It only shows few options to start with and the rest relevant options become available, as you type.
Screenshot: hidden link

This is useful especially when a large number of options are available as without it, the select list would be a very long one.
( there are 79 Specialties on your website )

#1462645
form-ids.png
process-condition-to-provider2.png
process-treatment-to-provider2.png
error.png

Thank you Waqar for answering those questions for us! We were able to successfully import our specific relationships using a CSV file and get the Specialty, Subspecialty forms to properly work.

Our last concern is regarding the Condition and Treatment checkbox form. The form properly displays the associated conditions and treatments, but it does not save them to the provider profile. Instead, it spits out an 'There has been a critical error on your website' message. Do you know why this may be happening?

Here is the code for our view to show the provider's form (placed in Templates for this View > Loop item in View to show current provider's form)

<h2>Specialty</h2>
[cred_form form='form-to-edit-a-provider-select-specialty' post='[wpv-post-id]']
[wpv-conditional if="( '[wpv-post-id item='@specialty-provider.parent']' ne '' )"] 
<h2 style="padding-top:40px;">Subspecialty</h2>
[cred_form form='form-to-edit-a-provider-select-subspecialty' post='[wpv-post-id]']
<script type="text/javascript">
jQuery(document).ready(function () {
    jQuery('input[type="radio"][name="select-subspecialty"][value="[wpv-post-id item="@subspecialty-provider.parent"]"]').attr('checked', 'checked');
});
</script>
[/wpv-conditional]
[wpv-conditional if="( '[wpv-post-id item='@subspecialty-provider.parent']' ne '' )"] 
<h2 style="padding-top:40px;">Conditions and Treatments</h2>
[cred_form form='form-to-edit-a-provider-select-condition-treatment' post='[wpv-post-id]']
<script type="text/javascript">
jQuery(document).ready(function () {
    jQuery('input[type="checkbox"][name="select-condition"][value="[wpv-post-id item="@subspecialty-provider.parent"]"]').attr('checked', 'checked');
});
</script>
[/wpv-conditional]

I have attached screenshots of the error message, form id for the condition and treatment form, and the code snippets for the process-treatment-to-provider / process-condition-to-provider

Thank you so much for all of your help!

#1462717
form-structure.png
form-with-and-without-subspecialty.png

We have another quick question about the overall setup of the form functionality.

There are some providers that only have a specialty and not a subspecialty. Take for instance an Acupuncturist. They have no subspecialty, but do treat conditions and perform treatments.

How would we setup our forms to show the related conditions and treatments if they select only a specialty, rather than being required to select a subspecialty?

Thank you in advance for all of your help! Take care.

#1463959

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for writing back and it's nice to see that these forms are shaping up nicely.

The error message "There has been a critical error on your website" is very generic but to get more specific details around such errors, you can turn WordPress debugging on.
https://wordpress.org/support/article/debugging-in-wordpress/

I personally use "WP PHP Console" plugin ( https://wordpress.org/plugins/wp-php-console/ ), which makes PHP errors and warnings much simpler to trace, through the browser's console.

One point that I noticed during quickly scanning the code in your screenshots is that the functions attached to "cred_save_data" hook for the "treatment-provider" and the "condition-provider" are missing the loop while connecting and disconnecting relationships.

In my example code for the "subspecialty-provider", it wasn't needed because a provider can connect to only one subspeciality at a time.

But in the case of these other two relationships, a provider can have multiple conditions and treatments. You'll understand this point better when you'll be debugging the results in "$existing_connections" and "$_POST" variables.

As for the other question, the way the relationships are structured, any layer in between like "subspecialty" can't be skipped, because the connections between providers & treatment and providers & conditions depend on it. For such few exceptions, the whole structure can't be compromised.

A simple workaround can be to save a subspeciality item with the same name as the specialty when none exists.
( for example, for "Acupuncturist" specialty, you can include a same-named subspeciality "Acupuncturist" )

I hope this helps and have a great weekend!

#1463965

Waqar,

Thank you very much! You, and the entire Toolset team, have been very helpful. Have a great weekend!

#1464009

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

You're very welcome and appreciate your kind words.

Please keep your questions coming - we're here to help!

Tip: Since this thread has already become very long, you can mark this one as resolved. For each new follow-up question or concern, you can start a new ticket.

#1464065

Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.