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...
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/
Got it. I figured it might not be possible, but I'll see about using that workaround. Thanks!