Advertisement
chrishajer

Update postmeta with URL of image attachment

Oct 8th, 2012
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.43 KB | None | 0 0
  1. <?php
  2. // http://www.gravityhelp.com/forums/topic/image-path-gform_after_submission#post-79385
  3. // original http://pastie.org/4927121
  4. add_action('gform_after_submission', 'update_form_post', 10, 2);
  5. function update_form_post($entry, $form) {
  6.     if($form['id'] != 20)
  7.         return;
  8.  
  9.     // update post image
  10.     $postid = $entry['post_id'];
  11.     $postimageurl = wp_get_attachment_url($postid);
  12.     update_post_meta($postid, 'thumb', $postimageurl);
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement