1

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);
        }

    });
0

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

});
  • Thank's Brad, that does work indeed. – Lukigi Nov 16 '16 at 10:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.