Answers.Body: <p>If you're just looking to update a custom field on the user, something like this should do it:</p>
  
  <pre><code>craft()-&gt;on('users.onBeforeSaveUser', function(Event $event) {
  
      if(craft()-&gt;request-&gt;isSiteRequest())
      {
          $companyId = craft()-&gt;request-&gt;getPost('email');
          $event-&gt;params['user']-&gt;getContent()-&gt;companyId = $companyId;
      }
  
  });
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-16T10:00:20.660Z
Answers.Text: Thank's Brad, that does work indeed.
Answers.UserDisplayName: Lukigi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-15T21:57:30.607Z
Answers.LastActivityDate: 2016-11-15T21:57:30.607Z
Answers.UserDisplayName: Brad Bell
Body: <p>I'm trying to write a simple plugin that will intercept registration form's data, manipulate it and move it forward. What I'm struggling with is how to set the Post content of a field after the manipulation.</p>
  
  <p>I'm trying to achieve something like that, how do I set the Post field after manipulation, setRawPostContent doesn't seem to work here.</p>
  
  <pre><code> craft()-&gt;on('users.onBeforeSaveUser', function(Event $event) {
  
          if(craft()-&gt;request-&gt;isSiteRequest())
          {
              $companyId = craft()-&gt;request-&gt;getPost('email');
              $event-&gt;params['user']-&gt;setRawPostContent('fields[companyId]', $companyId);
          }
  
      });
  </code></pre>
  
Tags: <plugin-development><usermodel>
Title: How do I set the Post field after manipulation
ThreadText: # How do I set the Post field after manipulation
  
  (Asked by: username_0 on 2016-11-14)
  
  I'm trying to write a simple plugin that will intercept registration form's data, manipulate it and move it forward. What I'm struggling with is how to set the Post content of a field after the manipulation.
  
  I'm trying to achieve something like that, how do I set the Post field after manipulation, setRawPostContent doesn't seem to work here.
  
  ```
   craft()->on('users.onBeforeSaveUser', function(Event $event) {
  
          if(craft()->request->isSiteRequest())
          {
              $companyId = craft()->request->getPost('email');
              $event->params['user']->setRawPostContent('fields[companyId]', $companyId);
          }
  
      });
  
  ```
  
  **Tags:** plugin-development, usermodel
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-11-15. Score: 0 | Accepted answer
  
  If you're just looking to update a custom field on the user, something like this should do it:
  
  ```
  craft()->on('users.onBeforeSaveUser', function(Event $event) {
  
      if(craft()->request->isSiteRequest())
      {
          $companyId = craft()->request->getPost('email');
          $event->params['user']->getContent()->companyId = $companyId;
      }
  
  });
  
  ```
  
  > **Comments:**
  > **username_0**: Thank's username_1, that does work indeed.  
  
  ---
  
  