title: Wordpress get_post_meta does not return when using variable
body: <p>I'm trying to get a plugin to read the post metadata of an attachment, and use it to update the content of the post it is attached to. I'm using the following in my themes function.php:</p>
  
  <pre><code>add_action( 'afip_created_post', 'get_desc', 10, 2 );
  function get_desc( $post_id, $attachment_id ) {
  
  $postmeta = get_post_meta ($attachment_id, '_wp_attachment_metadata', true);
  
      $meta = $postmeta['image_meta'];
      $mmwwdesc = $meta['description'];
      wp_update_post( array( 'ID' =&gt; $post_id, 'post_content'  =&gt; $mmwwdesc  ) );
  
  }
  </code></pre>
  
  <p>and then using this line in the plugin to hook the function</p>
  
  <pre><code>do_action( 'afip_created_post', $new_post_id, $post_id );
  </code></pre>
  
  <p>If I fill in the varibale "$attachment_id" with a number from another post i.e "15," I get the description inserted into the published post. If I change the output to <code>wp_update_post( array( 'ID' =&gt; $post_id, 'post_content'  =&gt; $attachment_id  ) );</code> I get the id number echoed in the body of the published post. I'm don't understand why the original code does not work, since $attachment_id seems to be properly defined. I'm just a beginner with php. Is there something obvious that I'm doing wrong? Is the variable <code>$attachment_id</code> being echoed when it should be returned, or something technical like that?   </p>
  
  <p>Background: I'm using two wordpress plugins, one called Media Metadata Workflow Wizard (MMWW), and the other called Automatic Featured Image Post (AFIP). MMWW extracts the image metadata and writes it to the database as post meta. AFIP creates new posts using uploaded media, and attaches each image to a post, setting it as the post thumbnail. I don't think its an issue of the metadata not being ready when the function is called, because AFIP creates the post after the media has been uploaded, and had its meta written to the database. I'm also hooking my function as an update to the post, after it has already been created.</p>
  
  <p>I've done extensive searching, and trial and error with no success. Can anybody help me out?</p>
  
  <p>Thanks!</p>