vitamineg
(vitamineg)
August 28, 2020, 6:08pm
1
Heyya, I’m wondering if Gravity Forms has a native way uploading images from a form submission to the Wordpress library yet?
I know Gravity Wiz has a plugin just for this but, I’m just trying to be as lightweight as possible …fewer plugins the better.
Thanks!
sacom
(Samuel Aguilera (Gravity Forms))
August 28, 2020, 10:56pm
2
Hi @vitamineg , is the form intended to create a post or just a regular entry?
vitamineg
(vitamineg)
August 28, 2020, 11:21pm
3
Intended to create a post.
sacom
(Samuel Aguilera (Gravity Forms))
August 29, 2020, 12:09am
4
If you use Gravity Forms core Post Creation feature, only the Post Image field type is attached to the media library: https://docs.gravityforms.com/post-image/
If that doesn’t fit your needs and you want to stick to the core functionality, you can use the gform_after_create_post hook that runs just after the post creation, and the media_sideload_image() WP core function https://codex.wordpress.org/Function_Reference/media_sideload_image to attach the files uploaded to the post.
The hook provides you the information that you need to pass to the media_sideload_image() function, the $entry object from where you can grab the values of the fields (the URL to the file) and the $post_id
Or if you have an Elite license, the Advanced Post Creation add-on https://www.gravityforms.com/add-ons/advanced-post-creation/ lets you attach to the media library files uploaded with any standard upload field https://docs.gravityforms.com/creating-a-feed-for-the-advanced-post-creation-add-on/#post-content
1 Like
vitamineg
(vitamineg)
August 29, 2020, 4:42am
5
Thank you @sacom . I think that’s what I need.
1 Like