Well, it's slightly complicated and I don't know of anyone who has posted a complete solution. In theory though, it would work like this:
Create a form with all the fields of the post you want people to be able to update. This could be similar to the form you currently use to create the post. I would not use post fields since that will create a new post. I would use regular form fields of the relevant type (file upload for a post image, single line text for the post title, paragraph for the post body, etc.)
Then, on the advanced tab of each field you want them to be able to edit, check the "Allow field to be populated dynamically" and give the field a unique parameter name.
Then, you would need to write a function that uses the gform_pre_render filter to pull information from the custom post to populate those fields. http://www.gravityhelp.com/documentation/page/Gform_pre_render
In the function, you would retrieve the information from the post you want to update, ( http://codex.wordpress.org/Function_Reference/get_post ) then populate the fields with that information. When the form is displayed, that information will be visible in the form, ready to be edited.
On submission, you would have to use the gform_after_submission hook to update the existing post ( http://codex.wordpress.org/Function_Reference/wp_update_post ). http://www.gravityhelp.com/documentation/page/Gform_after_submission You would take all the information that was submitted and rewrite (update) the existing post.
It's possible to do. You'd have to consider how to allow only certain users to update certain posts, and how to display the list of posts they can edit.
Another way around it would be to allow the logged in user to just edit the post on the front end. This would just be a WordPress plugin function. Something like this http://wordpress.org/extend/plugins/front-end-editor/
Good luck
Posted 11 years ago on Thursday January 24, 2013 |
Permalink