WordPress.org

Support

Support » Plugins and Hacks » [Plugin: FormBuilder] save and finish later function?

[Plugin: FormBuilder] save and finish later function?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Anyone?

    Hello,
    I also need to create a form with a ‘Save’ button.
    Does anyone have a suggestion?

    i never found a free one, tho i think ninja forms (paid) may offer this.
    the other option is write your own, or edit an existing plugin. most of those i looked at write each submission to a table, rather than overwrite old entries for the user’s id. that maybe coz wordpress (wpdb) doesn’t appear to have an easy sql function to ‘insert… or on duplicate update’ – so you’ll have to write one of those too using php with or without wpdb. here was my inefficient version – it makes 3 database requests per update:

    $all_rows = $wpdb->get_results( $wpdb->prepare("SELECT * FROM ".$table." WHERE ".$id_field." = '".$value."'") );
    	$num_rows = $wpdb->num_rows;
    
    	if ($num_rows==0){ // insert new
    		$is_er = $wpdb->prepare($wpdb->insert($table, $data, $sql_data));
    	}
    
    	if ($num_rows==1){ // update if 1
    		$is_er =$wpdb->prepare($wpdb->update($table, $data, array($id_field => $value), $sql_data));//
    	}
    ...

    or just purge the table of all existing entries for the id before you write
    e.g.: $wpdb->query($wpdb->prepare(" DELETE FROM " . $table . " WHERE registration_id ='" . $registration_id."'"));

    then of course you’ve got to get your answers out using sql… So it gets pretty ugly. I wish some clever plugin person could do it all for us

    Thanks for the reply.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: FormBuilder] save and finish later function?’ is closed to new replies.