-
Notifications
You must be signed in to change notification settings - Fork 14
Fixed errors related to creating a contact #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Previously, when sending data, a new contact was created with a new mtc_id. This problem was solved by correctly collecting cookies adding $request['header'][] = "Cookie: ". $data['COOKIES']; аfter public function prepareRequest(array $data)
add parsing fields from form
| $email = $_REQUEST['email'] ?? $_REQUEST['Email'] ?? $_REQUEST['E-mail'] ?? $_REQUEST['E-MAIL']; // mauticform_input_mkregistraciaslp_email | ||
| $name = $_REQUEST['name'] ?? $_REQUEST['Name']; // mauticform_input_mkregistraciaslp_name | ||
| $phone = $_REQUEST['phone'] ?? $_REQUEST['Phone']; // mauticform_input_mkregistraciaslp_phone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is too specific. It shouldn't be in the docs. Why would anyone need to check for 4 different email keys?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried using this file for various external services, such as website builders. It turned out that some people are passing parameters in upper case, and others in lower case. Somewhere it is necessary for third parties (web master, customer marketer) to register a variable manually. As a result, either we do the most universal and register-independent check of variables, or we take a long time to find out who made a mistake in writing a variable on the transmitting side.
| $form_id = $_REQUEST['form_id'] ?? $_REQUEST['Form_id']; // mauticform_input_mkregistraciaslp_form_id | ||
| if (is_null($form_id)) {$form_id = 1;} // if form_id is empty then use the 1'st Mautic form | ||
| $form = $mautic->getForm($form_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It must be a real Mautic form. The specific form that has the fields defined. It cannot default to 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, to speed up the start of work if the transmitter is not on our side. We can send a link to our script, create 1 form and immediately start accepting data. And then when the form ids are configured on an external resource, the data will begin to be distributed to the required forms in mautic
|
|
||
| // Require Composer autoloader | ||
| require __DIR__.'/vendor/autoload.php'; | ||
| // or require __DIR__.'/../../vendor/autoload.php'; if you place it not in the root folder, but for example in the /docroot/webhook/ folder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this obvious? The autoloader path must be correct and depends on where the vendor dir is relative to this PHP script. It may be different for everyone. Copy-pasting code and hoping it will work without understanding it will be a big issue now with ChatGPT, I know. But even the young developers must thing about what the example code does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is obvious to you, a senior programmer, but it is not obvious to a marketer who needs to send data to mautic from a website.
|
Hi, John |
|
I'm sorry. I don't understand the meaning of your comment. Can you point out which row from this PR is fixing the duplicate contact creation? |
|
When creating a contact through the form, a new mtc_id was created
Contacts are now created correctly