Skip Navigation

[Resolved] Form for deleting data in fields

This support ticket is created 4 years, 6 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.

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.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by Stina 4 years, 5 months ago.

Assisted by: Nigel.

Author
Posts
#1636385

I have a post type with several custom fields. I want users to be able to delete, but not edit, the content in two fields.
I've been looking around in the documentation and the options in the form building section.

#1637057

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

This is for front-end forms, yes?

There isn't an option to delete field values as such, in a form you "delete" them by editing them so that they have no value, which highlights the problem of allowing someone to delete a field without editing it.

I suggest that you have an edit form where you don't include inputs for these fields, you simply output the field values (as what looks like disabled inputs), and then include generic checkbox fields next to them where users can mark the field for deletion.

You will then need to handle the deletion using the API when the form is submitted, so using a hook such as cred_before_save_data (https://toolset.com/documentation/programmer-reference/cred-api/#cred_before_save_data), where you check the generic fields to see if checked, and if so use delete_post_meta (https://developer.wordpress.org/reference/functions/delete_post_meta/) to remove the field.

Does that sound like a viable option? If you need help with some of the details, let me know.

#1646035

I've made a workaround, thank you for the help.