Formidable only supports one draft per user and I needed to have an unlimited number of drafts per user. Exacerbating the problem for me was that I had a bazillion required fields, meaning I couldn't save it without either giving each one a value or defaulting all of them to something. That wasn't going to work. Here's how I solved it:
1. Added a hidden field to your form and give it a key "is_draft" (or whatever you want, as long as you propagate it through the next steps).
2. Form Settings->Form Permissions make sure "Allow logged-in users to save drafts" is unchecked.
3. Form Settings->Customize HTML change the following:
https://pastebin.com/AVgX6hnN
4. Add the following jQuery code to your page (replacing my_saveDraft and my_save with the same values in the previous step and field_is_draft with whatever you used in step 1.
https://pastebin.com/3FSeKfPe
5. To silence the required field errors, use frm_validate_entry as follows:
https://pastebin.com/NhA5zwcX
Please login or Register to submit your answer
This is great! The only issue is that it saves as completed instead of as a draft. Anyway around it?
You can use the https://formidableforms.com/knowledgebase/frm_after_update_entry/ or https://formidableforms.com/knowledgebase/frm_after_create_entry/ to adjust the is_draft value for the entry.
Thank you for your response. I'm trying the following code, but it's not quite right:
add_action('frm_after_create_entry', 'update_draft_status', 20, 2);
function update_draft_status($entry_id, $form_id){
if($form_id == 2){
global $wpdb;
if ($_POST['item_meta'][102] == "Yes") {
$wpdb->update( $wpdb->prefix .'frm_items', array('is_draft'=>1));
}else{
$wpdb->update( $wpdb->prefix .'frm_items', array('is_draft'=>0));
}
}
}
Well, you have to be more clear than "not quite right". What is it doing or not doing? One thing that's clear to me is that without a where clause (param 3 of wpdb->update) it's going to update all of your entries for every form.
Thanks! That would do it.
@Mark Koncurat after you updated the code from @Rob LeVine where you able to get success in saving different drafts for different users? I'm attempting to modify the code in the same way you are, but without the final results. Could you share them?