Modifies forms to pass api_version Modifies forms to pass store form-specific values (e.g., form_id, email) inside a separate data array
31 lines
871 B
PHP
31 lines
871 B
PHP
<?php
|
|
namespace MailPoet\Subscription;
|
|
|
|
use MailPoet\API\API;
|
|
use MailPoet\API\Endpoints\Subscribers;
|
|
use MailPoet\API\Response as APIResponse;
|
|
use MailPoet\Util\Url;
|
|
|
|
class Form {
|
|
static function onSubmit() {
|
|
$api = new API();
|
|
$api->getRequestData($_REQUEST);
|
|
$form_id = (!empty($_REQUEST['data']['form_id'])) ? $_REQUEST['data']['form_id']: false;
|
|
$response = $api->processRoute();
|
|
if($response->status !== APIResponse::STATUS_OK) {
|
|
Url::redirectBack(array(
|
|
'mailpoet_error' => ($form_id) ? $form_id : true,
|
|
'mailpoet_success' => null
|
|
));
|
|
} else {
|
|
(isset($response->meta['redirect_url'])) ?
|
|
Url::redirectTo($response->meta['redirect_url']) :
|
|
Url::redirectBack(
|
|
array(
|
|
'mailpoet_success' => $form_id,
|
|
'mailpoet_error' => null
|
|
)
|
|
);
|
|
}
|
|
}
|
|
} |