Hi, I'd like to give the users the permission to choose the parent page where to publish the new one
How can I do?
should I create a particular custom field?
Thank you in advance and grats for this wonderful plugin
Hi, I'd like to give the users the permission to choose the parent page where to publish the new one
How can I do?
should I create a particular custom field?
Thank you in advance and grats for this wonderful plugin
some help?
I haven't implemented any feature like this and you can't currently do it via a custom field. You'd have to create a new form widget that can select other pages and set them as parent. It's a good idea and I'll see if I can put it in the next release.
cool!
so, I think I will wait for the next release as I don't have enough skills to create this custom field by myself :)
thank you for your help and the great plugin!
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!
You must log in to post.