Hi,
I am wanting to know where the info goes once a person uploads it to our site using the form. If I want to specify a destination page, how do I do that?
Hi,
I am wanting to know where the info goes once a person uploads it to our site using the form. If I want to specify a destination page, how do I do that?
Any uploaded files will be stored in the wp-content/uploads/gravity_forms/$FORM_ID-randomstring folder. Any text entered in your form fields will be store in your WordPress database in dedicated Gravity Forms tables. A reference to any uploaded file will be stored in the database as well.
What is it you're trying to do that depends on knowing where the information is stored?
Second part:
I see that there is a redirect link in the forms settings at the top of each form under confirmation. Problem is I need all this info that will be uploaded to automatically load on to a destination page.
here is what I am doing.
Authors will be filling in their name, book title, book cover, book description and the book to upload to the site so that a free member can download their material. I am needing to have all this info populated to the destination page.
I believe it can be done using Gravity Forms..... I hope it can, LOL!
You can use the redirect option and then check the box "Pass Field Data Via Query String" and build your query string there using the merge tag drop down. You will have all the data which is submitted in the form available here. Your query string will look like this (to start):
aname={Name:1}&title={Book Title:6}&description={Your Book's Description:10}
And that will be combined with the URL you entered in the line above, so the visitor will be redirected to a page like this:
http://example.com/?aname=Chris Hajer&title=Everything About Everything&description=This is a super long description of my book, which is an awesome book
Then, the page you are redirecting to, the URL for the redirect, will need to accept and process all that information in the query string.
Hi Chris,
Thanks. I am going to go through this slowly as I am not that advanced in code. Once I see the whole idea it becomes easier so stay tuned for any potential replies. :)
Ok, good luck.
You said,
"Then, the page you are redirecting to, the URL for the redirect, will need to accept and process all that information in the query string."
1. Is this done automatically or do I need more code to get the page to accept and process?
2. I am putting together the string now: so far it is:
Name={Author Name:1}&email={Email:2}&website={Website:3}&title={Book Title}&description={Book Description}&tags={Book Tags}&image={Book Cover Image}
Do I add the url like this?
http://www.john316marketingnetwork.com/free-downloads/Name={Author Name:1}&email={Email:2}&website={Website:3}&title={Book Title}&description={Book Description}&tags={Book Tags}&image={Book Cover Image}
thanks for your patience Chris!
I forgot to add the numbers:
Name={Author Name:1}&email={Email:2}&website={Website:3}&title={Book Title:4}&description={Book Description:5}&tags={Book Tags:6}&image={Book Cover Image:7}&category={Book Category:8}&book={Upload Book File:9}
The URL field will hold this:
The query string will hold this:
Name={Author Name:1}&email={Email:2}&website={Website:3}&title={Book Title:4}&description={Book Description:5}&tags={Book Tags:6}&image={Book Cover Image:7}&category={Book Category:8}&book={Upload Book File:9}
Gravity Forms will put that together with a question mark right before the Name parameter, so the visitor will be directed to this page:
http://www.john316marketingnetwork.com/free-downloads/?Name={Author Name:1}&email={Email:2}&website={Website:3}&title={Book Title:4}&description={Book Description:5}&tags={Book Tags:6}&image={Book Cover Image:7}&category={Book Category:8}&book={Upload Book File:9}
Please note that parameter names are case sensitive, so use the same case in both places, and also, there is sometimes an issue with the word "name" as a parameter, so you may need to use "fullname" or something like that. See if it works as "Name" for you, but if not, be aware you might need to change that parameter name.
Thanks Chris,
How do I get all the uploaded content to automatically populate to this redirect page? Right now it becomes a blog post but without the book, cover, title, description, etc. My goal is to upload it and it populate to the url above.
thanks for all your help!
Joe
BTW - It does redirect ok as you directed above!
I'm not sure what you mean. You're sending the query string with parameters and values OK? Does something need to happen before that, with the form submission, or after that, with the query string values?
hi Chris,
I need something to happen after the gravity form is filled out. Authors are going to be using this form to upload their books to the "book launch site. The owner of the network wants all the uploads to appear on one single page instead of each upload appearing as individual blog posts. Hope that makes sense.
That makes sense. I don't think you're going to need to query string at all for that. You did not mention your end goal before so I was not really thinking about what you needed to do.
To update an existing page with additional information, you will have to use the gform_after_submission hook. http://www.gravityhelp.com/documentation/page/Gform_after_submission
That will run after the entry is created. You can then add all the information which was submitted, to an existing page. The first example here: http://www.gravityhelp.com/documentation/page/Gform_after_submission#Examples
shows how to update a post. You will be updating an existing page, so that post ID can be hard-coded. Then you will need to add your data to the end of that existing page, and then call wp_update_post to write the new content to the page.
Hi Chris,
This is great, thanks for taking the time to explain this. I have no problem learning a little advance coding. I only know standard html stuff. I am going to try this and the code to the functions.php
Couple questions:
When you said, "You will be updating an existing page, so that post ID can be hard-coded." Did you mean simply changing the word post to page or leaving the code as is?
Question 2:
"Then you will need to add your data to the end of that existing page, and then call wp_update_post to write the new content to the page. "
How do I do this? Or, does the gform_after_submission hook do it?
sorry for my ignorance.
When you said, "You will be updating an existing page, so that post ID can be hard-coded." Did you mean simply changing the word post to page or leaving the code as is?
In this code sample:
[php]<?php
add_action("gform_after_submission", "set_post_content", 10, 2);
function set_post_content($entry, $form){
//getting post
$post = get_post($entry["post_id"]);
//changing post content
$post->post_content = "Blender Version:" . $entry[7] . "<br/> <img src='" . $entry[8] . "'> <br/> <br/> " . $entry[13] . " <br/> <img src='" . $entry[5] . "'>";
//updating post
wp_update_post($post);
}
?>
You would not need to use $post = get_post($entry["post_id"]) since that is pulling the ID of the newly created post from the entry which was just submitted. You already know your post ID (even if it refers to a Page, it's still a post ID) so you can hard code that here. It would look like this, if the page you want to append your author/book data to is page 405:
[php]
$page_to_update = 405;
$post = get_post($page_to_update);
Then whatever code you use afterward, in this function, will apply to post (Page) 405.
Pages in WordPress are still just posts, with a post_type of 'page'. It's all stored in the $wpdb->posts table and the ID is necessary for pulling any content from that table.
"Then you will need to add your data to the end of that existing page, and then call wp_update_post to write the new content to the page. "
How do I do this? Or, does the gform_after_submission hook do it?
This is all in the function which you link to gform_after_submission. It will look something like this (not complete or fancy, but it illustrates the process):
[php]
<?php
add_action("gform_after_submission", "append_post_content", 10, 2);
function append_post_content($entry, $form){
// get the page we want to update
// page ID 405
$page_to_update = 405;
$page = get_post($page_to_update);
// append our new author submission
$page->post_content .= $page->post_content .
// separate the new submission from the last one
"<hr />" .
// add some of the information
"Book title: " . $entry[4] . "<br />" .
"Author: " . $entry[1] . "<br />" .
"Website: " . $entry[3] . "<br />" .
"<p>Description: " . $entry[5] . "</p>";
// continue until you have added all the fields
// update the page
wp_update_post($page);
}
Lines 10 to 18 above are all one line, broken apart to display better here.
Hi Chris,
Okay, I think it is sinking in now.
1. Do I use this exact form you have above to fill in my data?
2. Do I post this info in the functions.php file, and if so, where in the file, at the end?
I know I need to fill out the complete information as you said: "Continue until you have added all the fields." Here is how I would fill it out:
<?php
add_action("gform_after_submission", "append_post_content",
10, 2);
function append_post_content($entry, $form){
// get the page we want to update
// page ID upload-content
$page_to_update = upload-content;
$page = get_post($page_to_update);
// append our new author submission
$page->post_content .= $page->post_content .
// separate the new submission from the last one
"<hr />" .
// add some of the information
"Book title: " . $entry[4] . "" .
"Author Name: " . $entry[1] . "" .
"Upload Book File: " . $entry[8] . "" .
"Book Category: " . $entry[7] . "" .
"Book Tags: " . $entry[9] . "" .
"<p>Description: " . $entry[5] . "</p>";
"Website: " . $entry[3] . "" .
// continue until you have added all the fields
// update the page
wp_update_post($page);}
I am assuming that the lines in green are your notes and should be deleted, correct?
thanks again,
Joe
The lines in green are just explanatory comments. They don't show up in the rendered page. You can leave them, edit them to make them your own, or delete the lines.
My example was just a portion of the whole template, and was based on your early query string, where I guessed that the merge tags were accurate, so I used them.
The code does go in your theme's functions.php and it can go at the end. However, if the file ends with a ?> , this code will be fine. You don't actually need that closing ?> and the opening <?php from my code. You could delete them both.
If your file does NOT end with ?> then delete my <?php at the beginning.
My code was just a start to show you how it works. You might want to include additional information and additional formatting.
Hi Chris,
Yeah, I used the form as is and it still did not populate the info on the form to one page but at least it did not break the site. It did upload the photo to the media section of wordpress and it did create a post with the title and category info filled but not populate to a page in this case. I have no idea where the pdf went as I couldn't find it.
ok, I see the above info you wrote was just a part of the whole template. I have no idea how to write this type of code. I believe I can do it though I just have to learn. So, where would I start versus having you or someone hard code it all for me?
thanks,
Joe
I'm not sure what you mean about a PDF. Gravity Forms does not generate PDFs. Maybe you are using an add-on or plugin for that?
What happened when you used your code? Lines 11 to 21 should create a post with your static text (the part like "Book Tags: " and "Author Name: ") and the submitted values (things like $entry[9] and $entry[1]).
You're not restricting this code to any specific form, so it should run on all forms. Is that what you wanted?
I think you're close and if you keep at it, you'll get it.
Hi Chris,
The form did create a post, yes. I added 2 fields on the form one for image upload and one for the book upload. The book is the pdf document. The problem was when I submitted a test form to see if all worked ok it never added the image and book to the post. The image went to the Media library and I can't see where the book went.
My goal is to have the form do what I did in the widget on the sidebar of the sight. See http://www.john316marketingnetwork.com You will see a few books under Free Christian eBooks! I used a widget with simple html code which you know and understand. I need the gravity form to populate a page just like the widget here.
The thing is I need the landing page for the form to be the same for all who will be uploading their books.
thanks again, and yes, I think some of this is sinking in. I am just wanting to make sure I communicate the idea correctly.
If you used a Post Image field for the image upload, it should go to the media library, so that's correct. The PDF upload should go where all files uploaded with Gravity Forms go first: wp-content/uploads/gravity_forms/FORM_ID-randomstring/ (where the folder is a combination of the form ID first and then a hyphen and a random string.)
If those made it to the correct locations, then you just need to add some HTML to your content template. If the information is available in the entry because the visitor entered it, then you can use it in your post. For a file (which you wlll link to) and an image (which you need to embed with an image tag) there is a little more HTML required that just displaying the text.
Hi Chris,
Yes, I can see some extra html is required which I can do. Here is the problem I am having right now. I have no idea how to do the code as you have explained above. I partly understand some things but not enough to write the actual code to paste into the functions.php file.
If there is some basic training Gravity offers that can enlighten me, sure, I am up for it. Otherwise, I will need you to completely write this task for me. So sorry, I really tried to wrap my mind around it but I can see the foundation of how it all works is not in me yet. I broke the site a couple times trying, lol. It is okay now I was able to access ftp and remove what I wrote and fix it.
Let me know what to do next Chris. I really need to get this project done for the client. I am willing, if it is possible, to learn this. But, if it is not then I will need someone at Gravity, as your genius self, to do it for me.
Thanks for all the help!
Joe