I did this.
It’s not pretty, and there’s probably better ways to do this.
But you need to insert this “hack” code into your form:
Immediately before the form-start comment.
<?php
$this_forms_id = get_the_ID();
$this_page = get_page($this_forms_id);
$form_parent = $this_page->post_parent ;
?>
This sets some variables that contain information we need. The main one we need is $form_parent.
You need to pass this information to the backend-code, and this is where I think I did this wrong; but it works.
This stuff goes between form method tag, and the widget-start comment.
<div><input type=’hidden’ id=’formwpid’ name=’formwpid’ value='<?php echo $this_forms_id ; ?>’ /></div>
<div><input type=’hidden’ id=’formparent’ name=’formparent’ value='<?php echo $form_parent ; ?>’ /></div>
Then, on the backend, in a file I suppose I’m not supposed to touch; tdomf-form.php file, look for a function called tdomf_create_post($args). The variables passed to this function are in the form of an Associative Array called $args. When a form is submitted, the two new values are “formwpid” and “formparent”. These are just wordpress page ID numbers.
Further down in the tdomf_create_post() function, find the “$post = array (” statement. This is where our page attributes are loaded into the array named $post. We need to add a line in there, “post_parent” => $args[‘formparent’], (dont forget the comma). Then when tdomf_create_post() fires $post_ID = wp_insert_post($post); the extra post_parent parameter that you shoved into $post, now replaces the default post_parent attribute of 0, with the ID of the parent post of your FORM. Therefore, in terms of page hierarchy, you get a page that is a sibling of your FORM.
Of course, this breaks all your other forms, unless they’ve been similarly hacked to post that “formparent” parameter.
What I did, is I also put in a third parameter “ismycustomform”=true. Then I test for that value $args[‘ismycustomform’], and if it’s set to true, I add my post_parent parameter to $post. Otherwise, I let the post be the way it is by default.
There’s a lot of other things you can do: I set categories this way too. You can change your “hack” php to grab a different post’s ID to use as a parent, if you like.
I started to try to figure out how to add this functionality via a widget, but I didn’t have time to figure that out. Tight deadlines cause bad coding!