I thought I read earlier that Pages could not be created (only posts) but was wondering if I was imagining that. Is there any word on creating Pages using form submissions? Just curious.
Thanks
I thought I read earlier that Pages could not be created (only posts) but was wondering if I was imagining that. Is there any word on creating Pages using form submissions? Just curious.
Thanks
That can't be done via the UI, but the following code snippet will get the job done.
Place it in your template's functions.php file. Make sure to replace XXX with the appropriate form id.
add_filter("gform_post_data", "set_post_type", 10, 2);
function set_post_type($post_data, $form){
if($form["id"] == XXX){
$post_data["post_type"] = "page";
}
return $post_data;
}
Thanks Alex. I see I will just replace XXX with the ID of the form I want to use to create Pages. I can also see how to extend this even further to add things like the page template and parent page. Thank you for posting this.
Yes, you can basically manipulate the post however you want with this.
is anyone online that can help me install this. I just purchased it and can't find any documentation for installation...thanks, I am so frustrated!
This is a off topic for this thread, I've replied in a new thread in the support forum below.
http://forum.gravityhelp.com/topic/installating-gravity-forms?replies=1#post-1857
Hi there. I've tried the above but all I get is a blank browser page and find this in my php error log:
[21-Jan-2010 14:14:26] PHP Fatal error: Cannot redeclare set_post_type() in /Users/dani/Code/WP/wpmu/wp-content/themes/avartti-theme/functions.php on line 163
I had the same problem. I solved it by changing:
set_post_type()
to:
formXXX_post_type()
If you think of all the possibilities this will offer for custom post types...
We will be expanding the post field functionality to support custom post types (and pages) as an option in the field editor once WordPress 3.0 is released and custom post types become easier to access.
I there. Thanks for the help. I got the blank screens too and although the screen no longer goes white, your fix didn't work for me. It doesn't even give me the option to edit posts anymore. Any ideas?
The following code worked for me (I'm running WordPress 2.8.4):
add_filter("gform_post_data", "change_post_type", 10, 2);
function change_post_type($post_data, $form){
//only change post type on form id X
if($form["id"] != 1) // You need to change your form ID here
return $post_data;
// Add other page data to change
$post_data["post_type"] = "page";
$post_data["post_parent"] = 42;
return $post_data;
}
How can this:
$post_data["post_parent"] = 42;
be changed to pass the ParentId from the form?
Just to clarify, do you want to change it so that the "post_parent" is set to the page/post that the form is embedded to?
Hi, I have tried all of the above codes in the functions.php file, is that the wrong file? Or is this some kind of conflict? I get the following error no matter which one:
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.
Hi, is there a way to generate a page as per "We will be expanding the post field functionality to support custom post types (and pages) as an option in the field editor once WordPress 3.0 is released and custom post types become easier to access."
Or do I still need to modify functions.php?
A 500 internal server error means you have a syntax error in the file you just modified. Please post your functions.php to pastebin.com or pastie.org and we'll help you find the error. If you have access to logging on your host, the error should be logged as well.
Thanks, it's here
http://pastie.org/2725128
Oh also
[19-Oct-2011 17:58:20] PHP Fatal error: Cannot redeclare set_post_type() (previously declared in /home1/carclubb/public_html/diaperdeals/wp-includes/post.php:1323) in /home1/carclubb/public_html/diaperdeals/wp-content/themes/freshlife1/functions.php on line 28
Looks like the function name set_post_type is being used by WordPress, which is why you have this error. Rename the function, on two lines (22 and 23 in the pastie). Anything that won't conflict, like senat_set_post_type. Change that on both lines and see if that works. It will get rid of the fatal error for sure.
Thanks for the troubleshooting information. It helps a lot.