Custom field filter

<?php

//Use a filter to add data to the gravity form field that you assigned a populate dynamically name of "interview"
add_filter("gform_field_value_interview", "populate_interview");
function populate_interview($value){
$mp3_url = $_FILES['input_3']['name'];
return $mp3_url;
}

//Use an action hook to detect the post and add a custom field to the post
function populate_it($post){
if(isset($_FILES['input_3'])){
echo $_FILES['input_3']['name'];
echo $post;
add_post_meta($post,'interview',$_FILES['input_3']['name']);
}
}

add_action('publish_post','populate_it');

?>

3 Comments

You must be logged in to post a comment.


  1. Thanks...appreciate your quick response...I have been looking at the 'after' hook but not sure I'm up to the coding task...thought since all other fields are working that maybe it was something about the two fields within a table or some other reason that the data was not getting added/inserted...


  2. Hard to wrap my head around. You can intercept any GF submission and pass the data to a post meta value. The GF website has lots of examples of this.

    This snippet was to add the name of an mp3 to a new post created bt gravity forms.

    I added a snippet now for the after submission hook: http://code.hyperspatial.com/1621/gform-after-submission/

    You get the data by field id, then do whatever you want with it.


  3. Greetings Adam, I came across your site and code snippets trying to solve a problem with Gravity Forms with GF Custom Post Types plugin and the WPMU Fundraising plugin. I am no PHP expert, but you clearly are, and this idea looks like maybe it could work...

    http://code.hyperspatial.com/1158/custom-field-filter/

    I have built a form that enables a user to complete a fundraising submission and have every field submitting successfully to the Fundraising back end. (The Fundraising plugin has no 'front end' interface for users.)

    With the GF CPT, GF recognizes the custom post type of the Fundraiser plugin and its fields so everything works great...except two fields for 'rewards' (columns in an array or table called 'award levels') which has two fields for the data...

    wdf_award_amount wdf_award_description

    $250 Free trip to Disneyland
    $500 Free trip to plus hotel for two nights
    $1000 Free trip to plus hotel for two nights and free car rental

    Using a list with two fields in GF so the user can enter multiple rewards works fine...data is sent by the form...but cannot get it to populate the Fundraiser fields or add a new level in the backend fundraiser editor.

    Any help or direction you can provide would be great, or suggest how to use your code modified to work...?

    Thanks in advance