Skip Navigation

[Resolved] Send form notification with ONLY fields that were changed

This thread is resolved. Here is a description of the problem and solution.

Problem:

I have some post forms to edit existing content and I need a way to either hold the edits the user has made until they're reviewed

Solution:

There isn't such kind of built-in feature, the editing post form will override the custom field values, so the original field value will lost after user submit the editing post form.

As a workaround, you might consider these:

https://toolset.com/forums/topic/send-form-notification-with-only-fields-that-were-changed/#post-2273811

Relevant Documentation:

https://toolset.com/course-lesson/selecting-parent-posts-when-using-forms-to-create-child-items/

This support ticket is created 2 years, 11 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/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by jennZ 2 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#2273393

I have some post forms to edit existing content and I need a way to either hold the edits the user has made until they're reviewed (but still leave the original post published, which I'm assuming is understandably impossible) OR send a notification when the form is edited by the user.

I would need that notification to show exactly what fields were edited so I can make sure they match our guidelines, but I don't want to see the rest of the form fields that were not changed, as that would just get confusing and overwhelming.

I haven't been able to find anyone attempting something similar, so I'm not sure where to start or if this is possible...

#2273811

Hello,

There isn't such kind of built-in feature, the editing post form will override the custom field values, so the original field value will be lost after user submit the editing post form.
As a workaround, you might consider these:
1) Create two post types:
- My-post
- My-draft (with custom field "reviewed")

2) Setup one-to-many relationship between "My-post" and "My-draft"

3) Add a post form for creating new "My-draft" post(without field "reviewed"), and relate it with parent "My-post" post:
https://toolset.com/course-lesson/selecting-parent-posts-when-using-forms-to-create-child-items/

4) After user submit above "My-draft" post form, send an email notification to the editor, with the new "My-post" post link

5) In the single "My-draft" post, display:
a) "My-draft" post information + parent "My-post" information
b) Post form for editing "My-draft" post(with field "reviewed")
After editor enable field "reviewed" and submit above post form, use action hook cred_save_data to trigger a custom PHP function, in this PHP function

1) check the "reviewed" field is enabled
2) get the custom field values from "My-draft" post
https://developer.wordpress.org/reference/functions/get_post_meta/
3) Get parent "My-post" post ID:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post
4) Update parent "My-post" post field values
https://developer.wordpress.org/reference/functions/update_post_meta/

#2274361

Got it. I figured it might not be possible, but I'll see about using that workaround. Thanks!