title: Wordpress - How to use the PHP header() function
body: <p>I need to use PHP headers like <code>header( 'Location: http://location.com' );</code> or <code>header("Content-disposition: attachment; filename=$fileName");</code> from my wordpress plugin but it won't seem to how. I know that they need to be used before the page header is called, so I tried using the init hook:</p>
  
  <pre><code>add_action('init', 'test');
  
  function test() {
      header( 'Location: http://location.com' ) ;
  }
  </code></pre>
  
  <p>but it didn't work. </p>