title: Wordpress Shortcode not passing variable from function (Newbie)
body: <p>Here is the snippet of code in question: </p>
  
  <pre><code>function hoursearned_func($user) {
      $key = 'Service Hours Earned';
      if(isset($user[$key])) {
          $result = $user[$key];
      }
  return "Service Hours Earned: ".$result." Hours";
  }
  add_shortcode('hoursearned', 'hoursearned_func');
  </code></pre>
  
  <p>This small function simply returns the value of an array given the key, but when calling the shortcode, [hoursearned], it only displays:</p>
  
  <pre><code>Service Hours Earned: Hours
  </code></pre>
  
  <p>rather than:</p>
  
  <pre><code>Service Hours Earned: 200 Hours
  </code></pre>
  
  <p>Where 200 is a string that is returned by the function hoursearned_func given $user.</p>
  
  <p>For some reason Wordpress is not passing the returned variables from the functions to the shortcodes.  How can I get Wordpress to show the result from the function?</p>
  
  <p>Here is the full code if that helps... (note that all of this is being loaded as a plugin)
      
  
  <pre><code>//Dump CSV file (SalesForce Report) to php array to be parsed..
  add_action('dump_csv_array', 'dump_csv_array', 10);
  function dump_csv_array(){
      $data = array();
      $header = NULL;
      if (($file = fopen('http://blah.com/info.csv', 'r')) !==FALSE) { //The link to the CSV is insignificant
          while (($row = fgetcsv($file, 1000, ",")) !==FALSE) {
              if(!$header)
                  $header = $row;
              else
                  $data[] = array_combine($header, $row);
              }
      fclose($file);
      }
      return $data;
  }
  
  $multiarray = (array) dump_csv_array();
  global $current_user;
  get_currentuserinfo();
  $user_email = $current_user-&gt;user_email;
  
  //Parses the multidimensional array of Dumped CSV info. Looks up the current user's email and returns a single array of the current user's SalesForce information.  
  function parse_array($multiarray, $user_email){
      $array = (array) $multiarray;
      $email = $user_email;       
          if(is_user_logged_in() === true ) {
              foreach($array as $subarray) {
                  if(isset($subarray['Email']) &amp;&amp; $subarray['Email'] == $email) {
                      $data = $subarray;
                  }   
              }
          }
          else {
              return NULL;
          }
  return $data;
  }
  
  $user = parse_array($multiarray, $user_email);
  
  //Defines Shortcodes and their Functions
  function hoursearned_func($user) {
      $key = 'Service Hours Earned';
      if(isset($user[$key])) {
          $result = $user[$key];
      }
  return "Service Hours Earned: ".$result." Hours";
  }
  
  
  function hoursawarded_func($user) {
  $key = 'Service Hours Awarded';
      if(isset($user[$key])) {
          $result = $user[$key];
      }
  return "Service Hours Awarded: ".$result." Hours";
  }
  
  function rank_func($user) {
  $key = 'Rank';
      if(isset($user[$key])) {
          $result = $user[$key];
      }
  return "Rank: ".$result;
  }
  
  function memstatus_func($user) {
      $key = 'Membership Status';
      if(isset($user[$key])) {
          $result = $user[$key];
      }
  return "Status: ".$result;
  }
  
  function register($atts) {
      add_shortcode( 'hoursearned', 'hoursearned_func');
      add_shortcode( 'hoursawarded', 'servicehours_func');
      add_shortcode( 'rank', 'rank_func');
      add_shortcode( 'memstatus', 'memstatus_func');
  }
  add_action('init', 'register');
  var_dump(hoursearned_func($user));
  </code></pre>