How to get the user id when registration form is used. #1802
Unanswered
JulieVelghe
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Just double-checking on my end, and a Formie Entries field mapped to a Craft Entries field is working for me. Just ensure that the enabled sources are the same (an entry picked in the form is allowed to be picked in the Craft entries form for the user). But, like any integration, you can modify the payload that it sent to the provider before it's sent. In this case, it's not the traditional off-site API, it's Craft's element-saving function, but the concept still stands. See docs. use verbb\formie\events\SendIntegrationPayloadEvent;
use verbb\formie\integrations\elements\User;
use yii\base\Event;
Event::on(User::class, User::EVENT_BEFORE_SEND_PAYLOAD, function(SendIntegrationPayloadEvent $event) {
// $payload will be a UserElement, prepped and ready to be saved.
$payload = $event->payload;
}); So while you can hook into this, you shouldn't need to if you're mapping entries fields, and that should be working. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a question about some custom development I'm doing.
We have a registration form that has an elements integration to create a user. The user has an entry field representing a chosen field of study. The data for that field is on the main site.
The form is on a subsite, and it has a field where the user can select an entry from the main site (being a chosen field of study).
On the initial creating of the user, this field is not getting mapped and remains empty.
I have another form, to modify the user data. I used a custom module, where I checked in the event_after_submission, which field of study was chosen on that form and update the user data. That code works well:
I was wondering if I could do something similar for the inititial registration form. I'm guessing that the user is only created after the submission event, so what event can I tap in to? Is there a way to get the id of the newly created user, AND keep my form data where the chosen field of study is kept?
Beta Was this translation helpful? Give feedback.
All reactions