Answers.Body: <p>Off the top of my head and in no way tested or thought through, you could put some logic in your plugin's <code>init()</code> method:</p>
  
  <pre><code>public function init()
  {
      $username = craft()-&gt;request-&gt;getQuery('username');
  
      if ($username)
      {
          craft()-&gt;urlManager-&gt;setRouteVariables(array(
              'username' =&gt; $username
          ));
  
          craft()-&gt;runController('myPluginHandle/myPluginActionMethod');
      }
  }
  </code></pre>
  
  <p>Then in your plugins's controller:</p>
  
  <pre><code>class MyPluginController extends BaseController
  {
      protected $allowAnonymous = true;
  
      public function actionDoIt($username)
      {
          // Do your thing.
  
          $this-&gt;redirect('homepage');
      }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-28T05:18:43.797Z
Answers.LastActivityDate: 2015-02-28T05:18:43.797Z
Answers.UserDisplayName: Brad Bell
Body: <p>I want to create an event that triggers before the site loads to I grab the variables passed in the http header and send them to a plugin I have made.</p>
  
  <p>I will have a url like <a href="http://www.foo.com?username=abc123" rel="nofollow">http://www.foo.com?username=abc123</a></p>
  
  <p>I want it immediately trigger a controller method located at: <a href="http://www.foo.com/actions/myPlugin/myMethod" rel="nofollow">http://www.foo.com/actions/myPlugin/myMethod</a></p>
  
  <p>Im just not sure how to connect the dots.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-27T18:18:43.940Z
Comments.Text: Would you want it to redirect to http://www.foo.com/actions/myPlugin/myMethod or just execute it, but keep the http://www.foo.com/?username=abc123 URL?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-02-28T02:12:54.087Z
Comments.Text: I need it to execute it, then I will be redirecting to the index page
Comments.UserDisplayName: ConquestXD
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-29T08:09:32.127Z
Comments.Text: Didn't the approach Brad posted work for you?
Comments.UserDisplayName: carlcs
Tags: <events>
Title: Create event before site loads
ThreadText: # Create event before site loads
  
  (Asked by: username_0 on 2015-02-27)
  
  I want to create an event that triggers before the site loads to I grab the variables passed in the http header and send them to a plugin I have made.
  
  I will have a url like <http://www.foo.com?username=abc123>
  
  I want it immediately trigger a controller method located at: <http://www.foo.com/actions/myPlugin/myMethod>
  
  Im just not sure how to connect the dots.
  
  **Tags:** events
  
  > **Comments:**
  > **username_1**: Would you want it to redirect to http://www.foo.com/actions/myPlugin/myMethod or just execute it, but keep the http://www.foo.com/?username=abc123 URL?  
  > **username_0**: I need it to execute it, then I will be redirecting to the index page  
  > **username_2**: Didn't the approach username_1 posted work for you?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-02-28. Score: 1
  
  Off the top of my head and in no way tested or thought through, you could put some logic in your plugin's `init()` method:
  
  ```
  public function init()
  {
      $username = craft()->request->getQuery('username');
  
      if ($username)
      {
          craft()->urlManager->setRouteVariables(array(
              'username' => $username
          ));
  
          craft()->runController('myPluginHandle/myPluginActionMethod');
      }
  }
  
  ```
  
  Then in your plugins's controller:
  
  ```
  class MyPluginController extends BaseController
  {
      protected $allowAnonymous = true;
  
      public function actionDoIt($username)
      {
          // Do your thing.
  
          $this->redirect('homepage');
      }
  }
  
  ```
  
  
  ---
  
  