Skip to content
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

Fixed errors related to creating a contact #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

zaharovrd
Copy link

When creating a contact through the form, a new mtc_id was created
Contacts are now created correctly

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
Comment on lines +25 to +27
$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
Copy link
Owner

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?

Copy link
Author

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.

Comment on lines +28 to +30
$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);
Copy link
Owner

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.

Copy link
Author

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
Copy link
Owner

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.

Copy link
Author

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.

Comment on lines +143 to +144
// $request['header'][] = "Cookie: mautic_session_id=$sessionId";
// $request['header'][] = "Cookie: mautic_device_id=$sessionId";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's wrong with this library to set the cookies for you? I think I'll need more context. And the changes need a bit of cleanup. Leaving commented out code in the production code isn't very professional.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look into https://github.com/escopecz/mautic-form-submit/issues
The library did not work correctly. A new lead was created with a new mtc_id (leaving the anonymous user with the old mtc_id) I and other people wrote about this. In the end I had to fix it myself. Now everything works.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @escopecz, thanks for the library, it helps us a lot. Hello @zaharovrd, we are facing the same problem you described. Submitting the form creates a new contact. Can you please share your solution to solve this problem?
grafik

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants