title: WordPress Plugin - Notice: Undefined index error
body: <p>I'm playing around with a plugin that's a little out of date and trying to get it back up to standard but I've hit a brick wall. On line #25 of the php script below, it's throwing a <strong>Notice: Undefined index: zip_path</strong> error for <em>if($entry['zip_path']){</em>. </p>
  
  <p>What's even more strange is that it's working on a couple of my domains but not on others. It might be worthwhile adding that the 'other' websites are hosted on external servers to the one I've been testing it on.</p>
  
  <p>Can anyone provide some insight into why I'm receiving this Undefined index error?</p>
  
  <pre><code>&lt;?php defined('ABSPATH') or die("No direct access allowed.");
  
  require_once __DIR__ . '/vendor/autoload.php';
  
  if (class_exists("GFForms") &amp;&amp; !class_exists("GFBulkDownload")) {
  
      class GFBulkDownload {
  
          protected $name = 'Gravity Forms Bulk Download';
          protected $version = '1.0';
  
          public function __construct() {
              add_action("admin_enqueue_scripts",         array($this, 'addStyles'));
              add_action("gform_entry_created",           array($this, 'afterSubmission'), 1, 2);
              add_action("gform_pre_submission_filter",   array($this, 'preSubmissionFilter'), 10, 1);
              add_action("gform_entries_column_filter",   array($this, 'change_column_data'), 10, 5);
              add_filter('gform_custom_merge_tags',       array($this, 'custom_merge_tags'), 10, 4);
              add_filter('gform_replace_merge_tags',      array($this, 'replace_download_link'), 10, 7);
              add_action("gform_entry_detail",            array($this, 'addMetaToDetails'), 10, 2);
              add_filter('gform_notification',            array($this, 'before_email'), 10, 3);
          }
  
          function before_email( $notification, $form, $entry ) {
              $site = trailingslashit(get_bloginfo('url'));
              if($entry['zip_path']){
                  $url = $site.$entry['zip_path'];
                  $notification['message'] .= "\n\n &lt;a href='{$url}' &gt;Download All Files in Zip&lt;/a&gt;";
              }
              return $notification;
          }
  
          public function addStyles(){
              wp_register_style('gform_bulk_download_css', plugin_dir_url(__FILE__).'assets/css/style.css');
              wp_enqueue_style('gform_bulk_download_css');
          }
  
          public function addScripts(){
  
          }
  
          function addMetaToDetails($form, $entry){
              $zip = gform_get_meta($entry['id'], 'zip_path');
  
              if($zip){
                  $site_url = trailingslashit(get_bloginfo('url'));
                  $url = $site_url.$zip;
                  echo    "&lt;table cellspacing='0' class='widefat fixed entry-detail-view'&gt;
                              &lt;tr&gt;
                                  &lt;td colspan='2' class='entry-view-field-name' &gt;Zip File Download Link&lt;/td&gt;
                              &lt;/tr&gt;
                              &lt;tr&gt;
                                  &lt;td colspan='2' class='entry-view-field-value lastrow'&gt;
                                      &lt;a class='gfbd-btn' style='margin-left:0;' href='{$url}'&gt; Download All Files Zip &lt;i class='fa fa-download'&gt; &lt;/i&gt;&lt;/a&gt;
                                  &lt;/td&gt;
                              &lt;/tr&gt;
                          &lt;/table&gt;";
              }
          }
  
          public function preSubmissionFilter($form) {
  
              //Get upload path for form
              $form_upload_dir = GFFormsModel::get_upload_path($form['id']);
  
              //strip everything up to wp-content/....   so we can build a url
              $form_upload_dir_formatted = stristr($form_upload_dir, 'wp-content/');
  
              //decode json and remove slashes to get list of files
              $files_for_zip = json_decode(stripslashes($_POST['gform_uploaded_files']), true);
  
              if(!is_null($files_for_zip)){
                  //reset the array pointer
                  reset($files_for_zip);
  
                  // get the key of the first element (This is due to the format of the array  )          
                  $key = key($files_for_zip);
                  $zipArray = $files_for_zip[$key];
  
                  $zip = new ZipArchive();
                  $filename = 'files_' . md5(rand(0123456, 7890123)) . '.zip';
                  $file_path = trailingslashit($form_upload_dir) . $filename;
                  $zip-&gt;open($file_path, ZipArchive::CREATE);
                  foreach($zipArray as $file_info){
                      $zip-&gt;addFile($form_upload_dir . '/tmp/' . $file_info['temp_filename'], $file_info['uploaded_filename']);
                  }
                  $zip-&gt;close();
  
                  //Set the zip key for the $form object to the url for the zip file we created, minus the domainname so we can pass it to the entry
                  $form['zip'] = trailingslashit($form_upload_dir_formatted) . $filename;
              }
              return $form;
          }
  
          public function afterSubmission($entry, $form) {
              //update the Entry with a zip_file meta field with a link to the zip file that was created.
              if (isset($form['zip'])) {
                  gform_update_meta($entry['id'], 'zip_path', $form['zip']);
              }
          }
  
          function change_column_data($value, $form_id, $field_id, $lead, $query_string) {
              $form = GFFormsModel::get_form_meta($form_id);
              $zip_path = gform_get_meta($lead['id'], 'zip_path');
              $site_url = get_bloginfo('url');
              $full_url = trailingslashit($site_url) . $zip_path;
              foreach ($form['fields'] as $field) {
                  if ($field['type'] == 'fileupload' &amp;&amp; $field['multipleFiles'] == "1") {
                      $upload_field_id = $field['id'];
                  }
              }
              if ($upload_field_id == $field_id) {
                  if (!empty($zip_path)) {
                      return $value . " &lt;a class='gfbd-btn' href='$full_url'&gt; Download All &lt;i class='fa fa-download'&gt; &lt;/i&gt;&lt;/a&gt;";
                  }
              }
              return $value;
          }
  
          function custom_merge_tags($merge_tags, $form_id, $fields, $element_id) {
              $merge_tags[] = array('label' =&gt; 'Download All Files (Zip)', 'tag' =&gt; '{download_all_files_zip}');
              return $merge_tags;
          }
  
          function replace_download_link($text, $form, $entry, $url_encode, $esc_html, $nl2br, $format) {
              $custom_merge_tag = '{download_all_files_zip}';
              if (strpos($text, $custom_merge_tag) === false) {
                  return $text;
              } else {
                  $zip_path = gform_get_meta($entry['id'], 'zip_path');
                  $full_url = trailingslashit(get_bloginfo('url')) . $zip_path;
                  return str_replace($custom_merge_tag, $full_url, $text);
              }
          }
  
      }
  
      new GFBulkDownload();
  }
  </code></pre>
  
  <p>Thank you in advance.</p>