Gravity forms upload path

//Change upload directory for all forms

add_filter("gform_upload_path", "change_upload_path", 20, 2);
function change_upload_path($path_info, $form_id){
$path_info["path"] = "/new/path/";
$path_info["url"] = "http://new_url.com/images/";
return $path_info;
}

//Change upload directory for specific form, the "4" in the gform_upload_path_4 below is the form id and this is what you would change for the form you want to customize

add_filter("gform_upload_path_4", "change_upload_path");
function change_upload_path($path_info){
$path_info["path"] = "/new/path/";
$path_info["url"] = "http://new_url.com/images/";
return $path_info;
}

Attach files

<?php

//Add this snippet to functions.php - the 'input_3' is the name of the file upload field in gravity forms, the category 11 is the category your form posts to
function add_mp3_customfield($post){
if(isset($_FILES['input_3']) && in_category(11,$post)){
add_post_meta($post,'interview_mp3',$_FILES['input_3']['name']);
}
}
add_action('publish_post','add_mp3_customfield');
//End snippet number 1

//This is an example loop, for your template file, the real version creates links to play the mp3's but this example just prints out the filepath. Replace the number 8 with the id of your particular gravity form.

if( have_posts() ) : while ( have_posts() ) : the_post();

$mp3_filename = get_post_meta($post->ID, 'interview_mp3', true);
$mp3_path = 'http://' . $_SERVER['SERVER_NAME'] . '/wp-content/uploads/gravity_forms/8/' . date('Y') . '/' . date('m') . '/' . $mp3_filename;

echo $mp3_path;
echo '<br>';

endwhile;
endif;

?>

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');

?>

Gravity forms javascript

//Enqueue Gravity Forms CSS and scripts for use outside the loop
wp_enqueue_script("gforms_ui_datepicker", WP_PLUGIN_URL . "/gravityforms/js/jquery-ui/ui.datepicker.js", array("jquery"), "1.3.9", true);
wp_enqueue_script("gforms_datepicker", WP_PLUGIN_URL . "/gravityforms/js/datepicker.js", array("gforms_ui_datepicker"), "1.3.9", true);
wp_enqueue_script("gforms_conditional_logic_lib", WP_PLUGIN_URL . "/gravityforms/js/conditional_logic.js", array("gforms_ui_datepicker"), "1.3.9", true);
wp_enqueue_style("gforms_css", WP_PLUGIN_URL . "/gravityforms/css/forms.css");

Gravity External Form

<?php
// include wordpress and gravity forms outside wordpress
require( '../wp-load.php' );
wp_enqueue_script("gforms_ui_datepicker", WP_PLUGIN_URL . "/gravityforms/js/jquery-ui/ui.datepicker.js", array("jquery"), "1.3.9", true);
wp_enqueue_script("gforms_datepicker", WP_PLUGIN_URL . "/gravityforms/js/datepicker.js", array("gforms_ui_datepicker"), "1.3.9", true);
wp_enqueue_script("gforms_conditional_logic_lib", WP_PLUGIN_URL . "/gravityforms/js/conditional_logic.js", array("gforms_ui_datepicker"), "1.3.9", true);
wp_enqueue_style("gforms_css", WP_PLUGIN_URL . "/gravityforms/css/forms.css");
get_header(); ?>
<div id="content">
<div id="contentleft">
<div class="postarea">
<h1>My Membership Page</h1>
<div class="form">
<?php gravity_form(2, false, true); ?>
</div>
</div>
</div>
<?php include(TEMPLATEPATH."/sidebar.php");?>
</div>
<?php get_footer(); ?>

Gravity Forms file upload query

<?php

//Connect to Database
$gravity_post_id = get_the_ID();

$dbc = mysqli_connect('localhost','dankuniv_wp02','H0fx81McyP','dankuniv_wp02')
or die('Error connecting to Database');

//This query gets the secondary ID
$query = "SELECT id
FROM wp_rg_lead
WHERE post_id = $gravity_post_id
LIMIT 0 , 30";

$result = mysqli_query($dbc, $query);
$row = mysqli_fetch_array($result);

//The secondary ID from above
$secondary_id = $row[0];

if ($row[0] != ''){

//This query grabs the file URL
$query2 = "SELECT value
FROM wp_rg_lead_detail
WHERE lead_id = $secondary_id
AND field_number = 3
LIMIT 0 , 200";

$result2 = mysqli_query($dbc, $query2);
$row2 = mysqli_fetch_array($result2);

//Create Source file link:
if ($row2[0] == ''){
//Empty field - exit conditional;
}
else {
echo '<a href="' . $row2[0] . '"><img src="/graphics/download_source.png" /></a>';
}
}

//Close the Connection
mysqli_close($dbc);

?>

Gravity Forms taxonomy fix

<?php
//Tag to Taxonomy - A fix for gravity forms

function hyp_tag_to_taxonomy( $form ){
$id = $form['post_id'];
$raw_tag_list = $form['12'];
$tag_array = explode(',', $raw_tag_list);

foreach ($tag_array as $tag){
wp_set_object_terms( $id, $tag, 'collective',true);
}
}

add_action( 'gform_post_submission', 'hyp_tag_to_taxonomy' );

?>

Clear field - Gravity Forms

<!-- Load jQuery -->

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("jquery","1.3.2");
</script>

<!-- Gravity forms clear field -->

<script type="text/javascript">

jQuery(document).ready(function() {

jQuery.fn.cleardefault = function() {
return this.focus(function() {
if( this.value == this.defaultValue ) {
this.value = "";
}
}).blur(function() {
if( !this.value.length ) {
this.value = this.defaultValue;
}
});
};
jQuery(".input_clear input, .input_clear textarea").cleardefault();

});

</script>