Post review function

Question

I am building an Ads site and looking for a way to review the changes users can make to their profiles (before they are visible online).

I specify that everything happens directly from Fronted

To achieve this I tried with the following code in my function.php:

function postPending ($post_ID)
{
if (get_role ('subscriber'))
{
// Unhook this function
remove_action ('post_updated', 'postPending', 10, 3);

return wp_update_post (array ('ID' => $post_ID, 'post_status' => 'pending'));

// re-hook this function
add_action ('post_updated', 'postPending', 10, 3);
}
}
add_action ('post_updated', 'postPending', 10, 3); `

This actually works and every time a post is updated, it is automatically put in the "pending" state

The problem is that in this way the ad is no longer visible on the site.

What I need is a function that when you update a post, creates a copy for review, so that the ad (old version) remains online until the review is approved.

Thanks in advance!!!

0
cladif 2 months 0 Answers 14 views 0

Leave an answer