title: Combining date and time input data into one field with WPAlchemy metaboxes
body: <p>I'm trying to convert a metabox for date and time I'm currently using into a WPAlchemy metabox.</p>
  
  <p>I am currently combining the start date and start time into one field upon save.</p>
  
  <p><strong>This is the old save function:</strong></p>
  
  <pre><code>add_action ('save_post', 'save_event');
  
  function save_event(){
  
      global $post;
  
      // - still require nonce
  
      if ( !wp_verify_nonce( $_POST['event-nonce'], 'event-nonce' )) {
          return $post-&gt;ID;
      }
  
      if ( !current_user_can( 'edit_post', $post-&gt;ID ))
          return $post-&gt;ID;
  
      // - convert back to unix &amp; update post
  
      if(!isset($_POST["startdate"])):
          return $post;
          endif;
          $updatestartd = strtotime ( $_POST["startdate"] . $_POST["starttime"] );
          update_post_meta($post-&gt;ID, "startdate", $updatestartd );
  
      if(!isset($_POST["enddate"])):
          return $post;
          endif;
          $updateendd = strtotime ( $_POST["enddate"] . $_POST["endtime"]);
          update_post_meta($post-&gt;ID, "enddate", $updateendd );
  </code></pre>
  
  <p>Here are the new functions and fields for reference:</p>
  
  <pre><code>$custom_event_metabox = new WPAlchemy_MetaBox(array
  (
      'id' =&gt; '_custom_event_meta',
      'title' =&gt; 'Event Information',
      'template' =&gt; /event_meta.php',
      'types' =&gt; array('event'),
      'context' =&gt; 'normal',
      'priority' =&gt; 'high',
      'mode' =&gt; WPALCHEMY_MODE_EXTRACT,
      'save_filter' =&gt; 'event_save_filter',
      'prefix' =&gt; '_my_' // defaults to NULL
  ));
  
              &lt;li&gt;&lt;label&gt;Start Date&lt;/label&gt;
              &lt;?php $mb-&gt;the_field('startdate'); ?&gt;
              &lt;input type="text" name="&lt;?php $mb-&gt;the_name(); ?&gt;" value="&lt;?php $mb-&gt;the_value(); ?&gt;" class="tsadate" /&gt;
              &lt;/li&gt;
  
              &lt;li&gt;&lt;label&gt;Start Time&lt;/label&gt;
              &lt;?php $mb-&gt;the_field('starttime'); ?&gt;
              &lt;input type="text" name="&lt;?php $mb-&gt;the_name(); ?&gt;" value="&lt;?php $mb-&gt;the_value(); ?&gt;" class="tsatime" /&gt;
              &lt;span&gt;&lt;em&gt;Use 24h format (7pm = 19:00)&lt;/em&gt;&lt;/span&gt;
              &lt;/li&gt;
  
              &lt;li&gt;&lt;label&gt;End Date&lt;/label&gt;
              &lt;?php $mb-&gt;the_field('enddate'); ?&gt;
              &lt;input type="text" name="&lt;?php $mb-&gt;the_name(); ?&gt;" value="&lt;?php $mb-&gt;the_value(); ?&gt;" class="tsadate" /&gt;
              &lt;/li&gt;
  
              &lt;li&gt;&lt;label&gt;End Time&lt;/label&gt;
              &lt;?php $mb-&gt;the_field('endtime'); ?&gt;
              &lt;input type="text" name="&lt;?php $mb-&gt;the_name(); ?&gt;" value="&lt;?php $mb-&gt;the_value(); ?&gt;" class="tsatime" /&gt;
              &lt;span&gt;&lt;em&gt;Use 24h format (7pm = 19:00)&lt;/em&gt;&lt;/span&gt;
  </code></pre>
  
  <p>The issue I'm facing is I'm not entirely sure if I should be using the save_filter or the save_action, or how I should handle doing this ala WPAlchemy.</p>
  
  <p>This is what I have thus far:</p>
  
  <pre><code>function event_save_filter($meta, $post_id)
  {
  
      // the meta array which can be minipulated
      var_dump($meta);
  
      // the current post id
      var_dump($post_id);
  
      // fix: remove exit, exit here only to show you the output when saving
      //exit;
  
      // - convert back to unix &amp; update post
      if(!isset($_POST["startdate"])):
  return $post;
  endif;
  $updatestartd = strtotime ( $_POST["startdate"] . $_POST["starttime"] );
  update_post_meta($post-&gt;ID, "startdate", $updatestartd );
  </code></pre>
  
  <p>if(!isset($_POST["enddate"])):
      return $post;
      endif;
      $updateendd = strtotime ( $_POST["enddate"] . $_POST["endtime"]);
      update_post_meta($post->ID, "enddate", $updateendd );</p>
  
  <pre><code>    // filters must always continue the chain and return the data (passing it through the filter)
      return $meta;
  
  }
  </code></pre>
  
  <p>Will this work? And should it be a save_filter or a save_action?</p>
  
  <p>Any insight appreciated ;-)</p>