PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

gform_post_submission - add data to wp_postmeta

  1. craigedmonds
    Member

    I am trying to add some custom meta data to a post and am trying to use gform_post_submission as I am using V1.5.

    Below is the code/function I am supposed to be executing (inside my themes functions.php file), however the rows are not being created.

    add_action("gform_post_submission_8", "create_services_listing_entry", 10, 2);
    function create_services_listing_entry($entry, $form){
    
        //getting post
        $postid = get_post($entry["post_id"]);
    
    	//prepare the data for insertion into wp_postmeta
    	$ecpt_whmcsservicesid = $entry[23];
    	$ecpt_listingaddress = $entry[3];
    	$ecpt_listingtown = $entry[4];
    	$ecpt_listingpostcode = $entry[5];
    	$ecpt_listingcountry = $entry[6];
    	$ecpt_listingtel = $entry[7];
    	$ecpt_listingemail= $entry[9];
    	$ecpt_listingurl = $entry[9];
    	$ecpt_listingmainbanner = $entry[18];
    	$ecpt_listingkeywords = $entry[13];
    
    	//insert data into wp_postmeta
    	update_post_meta($postid, 'ecpt_whmcsservicesid', $ecpt_whmcsservicesid);
    	update_post_meta($postid, 'ecpt_listingaddress', $ecpt_listingaddress);
    	update_post_meta($postid, 'ecpt_listingtown', $ecpt_listingtown);
    	update_post_meta($postid, 'ecpt_listingpostcode', $ecpt_listingpostcode);
    	update_post_meta($postid, 'ecpt_listingcountry', $ecpt_listingcountry);
    	update_post_meta($postid, 'ecpt_listingtel', $ecpt_listingtel);
    	update_post_meta($postid, 'ecpt_listingemail', $ecpt_listingemail);
    	update_post_meta($postid, 'ecpt_listingurl', $ecpt_listingurl);
    	update_post_meta($postid, 'ecpt_listingmainbanner', $ecpt_listingmainbanner);
    	update_post_meta($postid, 'ecpt_listingkeywords', $ecpt_listingkeywords);
    
    }

    Any ideas what I am doing wrong here?

    Posted 13 years ago on Wednesday September 7, 2011 | Permalink
  2. craigedmonds
    Member

    [SOLVED]

    ok. I have figured it out

    I changed:
    $postid = get_post($entry["post_id"]);

    to

    $newpostid = $entry['post_id'];

    Now all my custom fields in my custom post type is inserted the data correctly.

    Posted 13 years ago on Thursday September 8, 2011 | Permalink
  3. Awesome. Glad you figured that out.

    Posted 13 years ago on Thursday September 8, 2011 | Permalink

This topic has been resolved and has been closed to new replies.