Skip Navigation

[Resolved] CRED Front-end Forms create revision on save

This support ticket is created 4 years 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 4 replies, has 2 voices.

Last updated by Raja Mohammed 4 years ago.

Assisted by: Raja Mohammed.

Author
Posts
#1842423

Hi,
Is It possible when the user save the front-end form this generate a revision into post?
Thanks

#1843197

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello there,

Front end forms is designed to create and edit a post and change its status , Also you cannot save a post revision without actually having the post in the database at least as Draft.

However you can use the Front End Forms API to create a revision of the post whenever it is edited through front end forms
for this purpose you can use the hook cred_submit_complete along with the WordPress function
wp_save_post_revision

The code would be like

add_action('cred_submit_complete', 'my_success_action',10,2);
function my_success_action($post_id, $form_data)
{
    // Run the code only for specific form
    if ($form_data['id']==12)
    {
         // Save the post revision
        //https://developer.wordpress.org/reference/functions/wp_save_post_revision/
         wp_save_post_revision($post_id);
    }
}

Reference :
https://toolset.com/documentation/programmer-reference/cred-api/#cred_submit_complete
https://developer.wordpress.org/reference/functions/wp_save_post_revision/

Regards
Raja

#1847437

Hi Raja,
i tried but the revision doesn't save.
The $form_data['id'] is correct.
Regards

#1847513

Hi Raja,
the revision doesn't work because i use custom fields.
It is possible active?
Regards

#1847557

Raja Mohammed
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes you are correct, The custom fields Revision cannot be saved that is a known limitation with WordPress .