<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>

CC BY-SA 3.0
2016-11-16T10:00:20.660Z
Thank's Brad, that does work indeed.
Lukigi
CC BY-SA 3.0
2016-11-15T21:57:30.607Z
2016-11-15T21:57:30.607Z
Brad Bell
<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>

<plugin-development><usermodel>
How do I set the Post field after manipulation
# 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 Brad, that does work indeed.  

---

