Skip Navigation

[Resolved] Save edit to meta field > Create small function which updates the main content?

This support ticket is created 5 years, 9 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by Dee_DeeA2948 5 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#1198060

Tell us what you are trying to do? Hello. I want to make posts visible---Even if they're not published.

My website allows front-end users to submit & edit their own posts. When they edit a post, the value moves from published to pending. Next, I have to approve the edits. The problem is that the post is NO LONGER visible to the public when the stage is not set to "published". I want the old version of the post to still be visible, and when I approve the edited version, the edits will be reflected.

Could I SAVE edit content to meta fields > Create small function which updates the main content fields?
On the save I believe I would need to update_post_meta($postID, 'pending_review', $the_edited_content);
Then when I come to approve, I would need: get_post_meta($post_id, 'pending_review', true) to get the data. Then depending on the verification, I would just pass that post meta to the posts content.

I was able to find this information online, but I'm still not 100% sure of what I'll need to do?

I found similar Toolset support tickets:
https://toolset.com/forums/topic/update_post_meta-on-save-not-updating/
https://toolset.com/forums/topic/deactivate-update_post_meta-for-some-custom-fields-in-some-post-types/

Thank you for your help!

#1198253

Hi, that's not exactly how WordPress workflow is designed. WordPress default workflow doesn't hold the changes for approval, it makes the changes immediately whether or not the post is immediately published. Say a lower-level User submits for approval a change to a post title in wp-admin. Even if the post status becomes "pending review" after the change, the change has already been made in the database. If you tried to show the post title of this now unpublished post, it would show the modified post title even before publishing approval. An admin can revert the change before publishing the post, sure, but until that older revision is published the existing title will show as having been changed. Toolset works within those workflow specifications, so there's no enqueueing of changes to post title, custom fields, taxonomies, etc.

If you wanted to enqueue changes with Toolset, it would take custom development. You would have to create multiple custom fields and use the PHP API to programmatically set the original field values with the new field values once the post becomes published. It will be tricky and will definitely require a professional developer. On the other hand, you may have better luck with a 3rd-party plugin that modifies revision workflows in WordPress without the need for extra custom code. There are several out there, but I don't really have a recommendation for one particular system.

#1202089

My issue is resolved now. Thank you!