Skip to content

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.

@zaharovrd
Copy link
Author

Hi, John
Let's fix the problem! I can bring my corrections as universal as possible, and you will look and include in the main branch. Agree, there is a problem that a new contact is being created each time ... I decided it.
But I see that you had changes to PHP8 and Mautic 5 - I do not have them. It is stupid to lead 2 branches)

@escopecz
Copy link
Owner

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?

@zaharovrd
Copy link
Author

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?
see this PR
8763613

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.

3 participants