Answers.Body: <p>I found a solution. Though I am not sure if this is the best way to go about it, but here's what I did:</p>
  
  <pre><code>&lt;input type="hidden" name="userType" value="org"&gt;
  </code></pre>
  
  <p>was added to the register form, and ...</p>
  
  <pre><code>$userType = craft()-&gt;request-&gt;getPost('userType');
  
  if ($userType == 'org')
  {
      // ...
  </code></pre>
  
  <p>was added to the onSaveUser event handler function.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-03T14:40:24.397Z
Answers.LastActivityDate: 2016-03-03T14:40:24.397Z
Answers.UserDisplayName: CodeMonkey
Body: <p><br></p>
  
  <p>I'm writing a customer portal plugin, utilizing Crafts user registration form: <a href="https://craftcms.com/docs/templating/user-registration-form" rel="nofollow">https://craftcms.com/docs/templating/user-registration-form</a></p>
  
  <pre><code>{# User registration form: #}
  &lt;form method="post" accept-charset="UTF-8"&gt;
      {{ getCsrfInput() }}
      &lt;input type="hidden" name="action" value="users/saveUser"&gt;
      &lt;input type="hidden" name="redirect" value=""&gt;
  
      {# What do I add / change ? #}
  
      {# ... #}
  &lt;/form&gt;
  </code></pre>
  
  <p><br> 
  My plugin has two different types of account profile records, <em>.._OrganizationProfileRecord</em> and <em>.._UserProfileRecord</em>. What I want to do is send a variable to the onSaveUser event handler in my plugin main class, to tell it what type of user was just saved (<em>"org"</em> or <em>"user"</em>), and then take appropriate actions, i.e. create either an organization or user profile.</p>
  
  <pre><code>class myPortalPlugin extends BasePlugin
  {
      public function init()
      { 
          craft()-&gt;on('users.onSaveUser', function(Event $event)
          {
              $craftUser = $event-&gt;params['user'];
              $isNewUser = $event-&gt;params['isNewUser'];
  
              if ($isNewUser)
              {
                  // Check if user is an organization or a regular user, and
                  // create the appropriate profile record.
  
                  // How do I check?
  
                  // ...
          }
      }
  
      // ...
  }
  </code></pre>
  
  <p><br></p>
  
  <h3>Questions: <br></h3>
  
  <ol>
  <li>How would I go about passing data/variable from the form to the onSaveUser event handler?<br></li>
  <li>Is there a better / more convenient way to do this?<br></li>
  </ol>
  
  <p>Many thanks in advance for any help you can provide in this matter!  <em>bowing</em></p>
  
  <p>/Monkey</p>
  
Tags: <plugin-development><user-profile><registration>
Title: How do I pass a hidden input value to plugin onSaveUser event handler?
ThreadText: # How do I pass a hidden input value to plugin onSaveUser event handler?
  
  (Asked by: username_0 on 2016-03-03)
  
  I'm writing a customer portal plugin, utilizing Crafts user registration form: <https://craftcms.com/docs/templating/user-registration-form>
  
  ```
  {# User registration form: #}
  <form method="post" accept-charset="UTF-8">
      {{ getCsrfInput() }}
      <input type="hidden" name="action" value="users/saveUser">
      <input type="hidden" name="redirect" value="">
  
      {# What do I add / change ? #}
  
      {# ... #}
  </form>
  
  ```
  
  My plugin has two different types of account profile records, *..\_OrganizationProfileRecord* and *..\_UserProfileRecord*. What I want to do is send a variable to the onSaveUser event handler in my plugin main class, to tell it what type of user was just saved (*"org"* or *"user"*), and then take appropriate actions, i.e. create either an organization or user profile.
  
  ```
  class myPortalPlugin extends BasePlugin
  {
      public function init()
      { 
          craft()->on('users.onSaveUser', function(Event $event)
          {
              $craftUser = $event->params['user'];
              $isNewUser = $event->params['isNewUser'];
  
              if ($isNewUser)
              {
                  // Check if user is an organization or a regular user, and
                  // create the appropriate profile record.
  
                  // How do I check?
  
                  // ...
          }
      }
  
      // ...
  }
  
  ```
  
  ### Questions:
  
  1. How would I go about passing data/variable from the form to the onSaveUser event handler?
  2. Is there a better / more convenient way to do this?
  
  Many thanks in advance for any help you can provide in this matter! *bowing*
  
  /Monkey
  
  **Tags:** plugin-development, user-profile, registration
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2016-03-03. Score: 1 | Accepted answer
  
  I found a solution. Though I am not sure if this is the best way to go about it, but here's what I did:
  
  ```
  <input type="hidden" name="userType" value="org">
  
  ```
  
  was added to the register form, and ...
  
  ```
  $userType = craft()->request->getPost('userType');
  
  if ($userType == 'org')
  {
      // ...
  
  ```
  
  was added to the onSaveUser event handler function.
  
  
  ---
  
  