In this case,
You can create a custom config file, in apps/customer/config/ and name it main-custom.php.
Put following contents into it:
PHP:
<?php defined('MW_PATH') || exit('No direct script access allowed');
return array(
'components' => array(
'request' => array(
'noCsrfValidationRoutes' => array('guest/*'),
),
),
);
The above means that your gues pages aren't protected by a CSRF token anymore, which means you can make post requests to this page from external websites, like your wordpress website.
So now you can:
1. Simplest way:
Create a form in wordpress with the action to the
http://www.yoursite.com/customer/index.php/guest/index and whan somebody fills in the info there and click submit, it will target the actual login page in mailwizz.
2. Harder way:
Create a controller in mailwizz, where you post info from your website and when the form is submitted, via ajax to a file on your wordpress, you make a curl request to this controller and check if the user/pass are valid and then return a json response. If the response is not successful, then you show the errors, otherwise if the response is successful and the user exists, then you simply change the action of the original form into the mailwizz login url and submit the data to there, all this by using javascript.
The reason why you do this is to keep the user on your wordpress website till you are sure his credentials for mailwizz are fine, and once they are, you let it go to the actual mailwizz login form.
To illustrate this:
Code:
$('#login-form').on('submit', function(){
var $this = $(this);
if ($this.data('skip-all')) {
return true;
}
$.post('/your/wordpress/url', formData, function(json){
if (json.result == 'success') {
$this.data('skip-all', true).attr('action', '/your-mailwizz-login-url').submit();
} else {
// do something with the errors
}
});
return false;
});
And the code that responds to the url: /your/wordpress/url should be something like:
PHP:
// send the data to your new controller and validate it, return an array with info
$response = curl_to_your_new_mailwizz_controller_and_send_all_the($_POST);
$response = json_encode($response)
exit($response);
Of course, if your wordpress and mailwizz are on same domain, you can implement the login into your newly created controller in mailwizz and post via ajax from wordpress to mailwizz.
You can simply take the GuestController.php copy it into another file and make it's actions return json content that you can later read from ajax.
That's pretty much it
![Big Grin :D :D](https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f600.png)