title: Export User Info into CSV - Additional Column
body: <p>I'm using the 'Export Users to CSV' a plugin for wordpress. By default, The plugin only extracts wp_users and wp_usermeta </p>
  
  <p>I have been wanting to add post_title column from wp_posts. I was able to pull out the 'post_title' into the CSV file BUT it's not placed correctly in its respective row. </p>
  
  <p>Please see my edited code and original code</p>
  
  <p>Orignal version:</p>
  
  <pre><code>global $wpdb;
  $data_keys = array(
      'ID', 'user_login', 'user_pass',
      'user_nicename', 'user_email', 'user_url',
      'user_registered', 'user_activation_key', 'user_status',
      'display_name'
  );
  $meta_keys = $wpdb-&gt;get_results( "SELECT distinct(meta_key) FROM $wpdb-&gt;usermeta" );
  $meta_keys = wp_list_pluck( $meta_keys, 'meta_key' );
  $fields = array_merge( $data_keys, $meta_keys);
  
  $headers = array();
  foreach ( $fields as $key =&gt; $field ) {
      if ( in_array( $field, $exclude_data ) )
          unset( $fields[$key] );
      else
          $headers[] = '"' . strtolower( $field ) . '"';
  }
  echo implode( ',', $headers ) . "\n";
  
  foreach ( $users as $user ) {
      $data = array();
      foreach ( $fields as $field ) {
          $value = isset( $user-&gt;{$field} ) ? $user-&gt;{$field} : '';
          $value = is_array( $value ) ? serialize( $value ) : $value;
          $data[] = '"' . str_replace( '"', '""', $value ) . '"';
      }
      echo implode( ',', $data ) . "\n";
  }
  </code></pre>
  
  <p>Edited version</p>
  
  <pre><code>global $wpdb;
  
  $data_keys = array(
      'ID', 'user_login', 'user_pass',
      'user_nicename', 'user_email', 'user_url',
      'user_registered', 'user_activation_key', 'user_status',
      'display_name'
  );
  $meta_keys = $wpdb-&gt;get_results( "SELECT distinct(meta_key) FROM $wpdb-&gt;usermeta" );
  $meta_keys = wp_list_pluck( $meta_keys, 'meta_key' );
  $post_keys = $wpdb-&gt;get_results( "SELECT distinct(post_title) FROM $wpdb-&gt;posts" );
  $post_keys = wp_list_pluck( $post_keys, 'post_title' );
  $fields = array_merge( $data_keys, $meta_keys, $post_keys);
  
  $headers = array();
  foreach ( $fields as $key =&gt; $field ) {
      if ( in_array( $field, $exclude_data ) )
          unset( $fields[$key] );
      else
          $headers[] = '"' . strtolower( $field ) . '"';
  }
  echo implode( ',', $headers ) . "\n";
  
  foreach ( $users as $user ) {
      $data = array();
      foreach ( $fields as $field ) {
          $value = isset( $user-&gt;{$field} ) ? $user-&gt;{$field} : '';
          $value = is_array( $value ) ? serialize( $value ) : $value;
          $data[] = '"' . str_replace( '"', '""', $value ) . '"';
      }
      echo implode( ',', $data ) . "\n";
  }
  </code></pre>
  
  <p>I hope my explanation is not confusing. Cheers!</p>
  
  <p>Here's an image to explain it better : </p>
  
  <p><a href="https://www.dropbox.com/s/xijkb4fp16atcx3/question-jpeg.jpg?dl=0">https://www.dropbox.com/s/xijkb4fp16atcx3/question-jpeg.jpg?dl=0</a></p>