/** * @see OptimizePress_Modules_Email_ProviderInterface::subscribe() */ public function subscribe($data) { $this->logger->info('Subscribing user (MailPoet): ' . print_r($data, true)); if (isset($data['list']) && isset($data['email'])) { // Formating data $convertedData = $this->prepareMergeVars(); $convertedData['user']['email'] = $data['email']; $convertedData['user_list']['list_ids'] = array($data['list']); $helperUser = WYSIJA::get('user', 'helper'); $status = $helperUser->addSubscriber($convertedData); $this->logger->notice('Subscription status (MailPoet): ' . print_r($status, true)); // Lets check if user is already subscribed $errorMessages = $helperUser->getMsgs(); if (!empty($errorMessages) && isset($errorMessages['updated']) && false !== array_search("Oops! You're already subscribed.", $errorMessages['updated'])) { $this->logger->notice('User already subscribed (MailPoet).'); if (isset($_POST['already_subscribed_url']) && op_post('already_subscribed_url') !== '') { $_POST['redirect_url'] = op_post('already_subscribed_url'); } else { if (isset($_POST['redirect_url'])) { $action = sprintf(__('<a href="javascript:history.go(-1);">Return to previous page</a> or <a href="%s">continue</a>.', 'optimizepress'), op_post('redirect_url')); } else { $action = __('<a href="javascript:history.go(-1);">Return to previous page.</a>', 'optimizepress'); } op_warning_screen(__('This email is already subscribed...', 'optimizepress'), __('Optin form - Warning', 'optimizepress'), $action); } return false; } $this->logger->info('User added to list (MailPoet)'); return true; } else { $this->logger->alert('Mandatory information not present [list and/or email address]'); wp_die('Mandatory information not present [list and/or email address].'); return false; } }
/** * @see OptimizePress_Modules_Email_ProviderInterface::subscribe() */ public function subscribe($data) { $this->logger->info('Subscribing user: '******'list']) && isset($data['email'])) { $params = $this->prepareMergeVars(); try { $status = $this->getClient()->addContact($data['list'], op_post('name') !== false ? op_post('name') : 'Friend', $data['email'], 'standard', 0, $params); $this->logger->notice('Subscription status: ' . print_r($status, true)); /* * If error occured (already subscribed user will be triggering error) * and already_subscribed_url param is filled then we hijack redirect_url param */ if (empty($status) && isset($_POST['already_subscribed_url']) && !empty($_POST['already_subscribed_url'])) { $_POST['redirect_url'] = op_post('already_subscribed_url'); } } catch (Exception $e) { $this->logger->error('Error ' . $e->getCode() . ': ' . $e->getMessage()); return false; } return true; } else { $this->logger->alert('Mandatory information not present [list and/or email address]'); wp_die('Mandatory information not present [list and/or email address ].'); return false; } }
/** * @see OptimizePress_Modules_Email_ProviderInterface::subscribe() */ public function subscribe($data) { $this->logger->info('Subscribing user: '******'list']) && isset($data['email'])) { $fields = $this->prepareMergeVars($data['list']); $status = $this->getClient()->import_single_member($data['email'], $fields, array($data['list']), $data['signup_form_id']); $this->logger->notice('Subscription status: ' . print_r($status, true)); if (!isset($status->added) || (int) $status->added !== 1) { if (isset($_POST['already_subscribed_url']) && op_post('already_subscribed_url') !== '') { $_POST['redirect_url'] = op_post('already_subscribed_url'); } else { if (isset($_POST['redirect_url'])) { $action = sprintf(__('<a href="javascript:history.go(-1);">Return to previous page</a> or <a href="%s">continue</a>.', 'optimizepress'), op_post('redirect_url')); } else { $action = __('<a href="javascript:history.go(-1);">Return to previous page.</a>', 'optimizepress'); } op_warning_screen(__('This email is already subscribed...', 'optimizepress'), __('Optin form - Warning', 'optimizepress'), $action); } return false; } return true; } else { $this->logger->alert('Mandatory information not present [list and/or email address]'); wp_die('Mandatory information not present [list and/or email address].'); return false; } }
/** * @see OptimizePress_Modules_Email_ProviderInterface::subscribe() */ public function subscribe($data) { $this->logger->info('Subscribing user: '******'list']) && isset($data['email'])) { $list = $this->getListById($data['list']); $params = array('email' => $data['email'], 'name' => false === op_post('name') ? '' : op_post('name')); if (null === $list) { $this->logger->error('Error: list ' . $data['list'] . ' not found'); wp_die('Error when subscribing user: '******'List not found [' . $data['list'] . ']'); } $mergeVars = $this->prepareMergeVars($list); if (null !== $mergeVars) { $params['custom_fields'] = $mergeVars; } try { $status = $list->subscribers->create($params); $this->logger->notice('Subscription status: ' . print_r($status, true)); } catch (OP_AWeberAPIException $e) { $this->logger->error('Error ' . $e->type . ': ' . $e->message); if (trim($e->message) == 'email: Subscriber already subscribed.') { if (isset($_POST['redirect_url'])) { $action = sprintf(__('<a href="javascript:history.go(-1);">Return to previous page</a> or <a href="%s">continue</a>.', OP_SN), op_post('redirect_url')); } else { $action = __('<a href="javascript:history.go(-1);">Return to previous page.</a>', OP_SN); } op_warning_screen(__('This email is already subscribed...', OP_SN), __('Optin form - Warning', OP_SN), $action); } } return true; } else { $this->logger->alert('Mandatory information not present [list and/or email address]'); wp_die('Mandatory information not present [list and/or email address].'); } }
/** * @see OptimizePress_Modules_Email_ProviderInterface::subscribe() */ public function subscribe($data) { $this->logger->info('Subscribing user (CampaignMonitor): ' . print_r($data, true)); if (isset($data['list']) && isset($data['email'])) { $mergeVars = $this->prepareMergeVars($data['list']); $subscriber = array('EmailAddress' => $data['email'], 'Name' => op_post('Name') ? op_post('Name') : '-', 'CustomFields' => $mergeVars); $status = $this->getSubscribersClient($data['list'])->import(array($subscriber), true, true, true); $this->logger->notice('Subscription status (CampaignMonitor): ' . print_r($status, true)); // Check if user was already subscribed earlier if ($status->was_successful() && isset($status->response->TotalNewSubscribers) && (int) $status->response->TotalNewSubscribers === 0 && isset($_POST['already_subscribed_url']) && op_post('already_subscribed_url') !== '') { $_POST['redirect_url'] = op_post('already_subscribed_url'); return false; } /* * Displays error */ if (!$status->was_successful()) { $this->logger->error('Error ' . $status->response->Code . ': ' . $status->response->Message); return false; } return true; } else { $this->logger->alert('Mandatory information not present [list and/or email address] (CampaignMonitor)'); wp_die('Mandatory information not present [list and/or email address].'); return false; } }
/** * @see OptimizePress_Modules_Email_ProviderInterface::subscribe() */ public function subscribe($data) { $this->logger->info('Subscribing user: '******'list']) && isset($data['email'])) { $status = op_post('double_optin') === 'Y' ? 0 : 1; $params = array('apikey' => $this->apiKey, 'plugin_key' => 'bb78ce44c9f6e99dd85ddd30fb782695', 'listID' => $data['list'], 'email' => $data['email'], 'status' => $status); $params = array_merge($params, $this->prepareMergeVars($data['list'])); $this->logger->info('params: ' . print_r($params, true)); $user = $this->getClient()->call('addSubscriber', $params); if (isset($user['ERROR'])) { if ($user['ERROR'] === 'EMAIL_ALREADY_EXISTS') { if (isset($_POST['already_subscribed_url']) && op_post('already_subscribed_url') !== '') { $_POST['redirect_url'] = op_post('already_subscribed_url'); } else { if (isset($_POST['redirect_url'])) { $action = sprintf(__('<a href="javascript:history.go(-1);">Return to previous page</a> or <a href="%s">continue</a>.', 'optimizepress'), op_post('redirect_url')); } else { $action = __('<a href="javascript:history.go(-1);">Return to previous page.</a>', 'optimizepress'); } op_warning_screen(__('This email is already subscribed...', 'optimizepress'), __('Optin form - Warning', 'optimizepress'), $action); } } return false; } return true; } else { $this->logger->alert('Mandatory information not present [list and/or email address]'); wp_die('Mandatory information not present [list and/or email address].'); return false; } }
/** * @see OptimizePress_Modules_Email_ProviderInterface::subscribe() */ public function subscribe($data) { $this->logger->info('Subscribing user: '******'list']) && isset($data['email'])) { $fields = $this->prepareMergeVars(); $status = $this->getClient()->subscribeContact($data['list'], $data['email'], $fields); $this->logger->notice('Subscription status: ' . print_r($status, true)); /* * Displays error */ if (false === $status) { if (isset($_POST['already_subscribed_url']) && op_post('already_subscribed_url') !== '') { $_POST['redirect_url'] = op_post('already_subscribed_url'); } else { if (isset($_POST['redirect_url'])) { $action = sprintf(__('<a href="javascript:history.go(-1);">Return to previous page</a> or <a href="%s">continue</a>.', OP_SN), op_post('redirect_url')); } else { $action = __('<a href="javascript:history.go(-1);">Return to previous page.</a>', OP_SN); } op_warning_screen(__('This email is already subscribed...', OP_SN), __('Optin form - Warning', OP_SN), $action); } return false; } return true; } else { $this->logger->alert('Mandatory information not present [list and/or email address]'); wp_die('Mandatory information not present [list and/or email address].'); return false; } }
/** * @see OptimizePress_Modules_Email_ProviderInterface::subscribe() */ public function subscribe($data) { $this->logger->info('Subscribing user: '******'list']) && isset($data['email'])) { $mergeVars = $this->prepareMergeVars($data['list']); $status = $this->getClient()->listSubscribe($data['list'], $data['email'], $mergeVars, 'html', op_post('double_optin') === 'Y' ? true : false); $this->logger->notice('Subscription status: ' . print_r($status, true)); /* * Displays error */ if (false === $status) { $this->logger->error('Error ' . $this->getClient()->errorCode . ': ' . $this->getClient()->errorMessage); if ($this->getClient()->errorCode == 214) { if (isset($_POST['redirect_url'])) { $action = sprintf(__('<a href="javascript:history.go(-1);">Return to previous page</a> or <a href="%s">continue</a>.', OP_SN), op_post('redirect_url')); } else { $action = __('<a href="javascript:history.go(-1);">Return to previous page.</a>', OP_SN); } op_warning_screen(__('This email is already subscribed...', OP_SN), __('Optin form - Warning', OP_SN), $action); } } return true; } else { $this->logger->alert('Mandatory information not present [list and/or email address]'); wp_die('Mandatory information not present [list and/or email address].'); } }
/** * @see OptimizePress_Modules_Email_ProviderInterface::subscribe() */ public function subscribe($data) { $this->logger->info('Subscribing user: '******'list']) && isset($data['email'])) { $fields = $this->prepareMergeVars($data['list'], $data['email']); $this->logger->info('Prepared Merge Vars: ' . print_r($fields, true)); $status = $this->getClient()->api("contact/add", $fields); $this->logger->notice('Subscription status: ' . print_r($status, true)); if ($status->success == 1) { $this->logger->notice('User Added to List'); return true; } else { if (strpos($status->result_message, 'is in the system already')) { if (isset($_POST['already_subscribed_url']) && op_post('already_subscribed_url') !== '') { $_POST['redirect_url'] = op_post('already_subscribed_url'); } else { if (isset($_POST['redirect_url'])) { $action = sprintf(__('<a href="javascript:history.go(-1);">Return to previous page</a> or <a href="%s">continue</a>.', 'optimizepress'), op_post('redirect_url')); } else { $action = __('<a href="javascript:history.go(-1);">Return to previous page.</a>', 'optimizepress'); } op_warning_screen(__('This email is already subscribed...', 'optimizepress'), __('Optin form - Warning', 'optimizepress'), $action); } } return false; } } else { $this->logger->alert('Mandatory information not present [list and/or email address]'); wp_die('Mandatory information not present [list and/or email address].'); return false; } }
/** * @see OptimizePress_Modules_Email_ProviderInterface::subscribe() */ public function subscribe($data) { if (isset($data['list']) && isset($data['email'])) { $mergeVars = $this->prepareMergeVars(); try { $contact = $this->getClient()->addContact($data['email'], 'normal', $mergeVars['prefix'], $mergeVars['name'], $mergeVars['last_name'], $mergeVars['sufix'], $mergeVars['street'], $mergeVars['street2'], $mergeVars['city'], $mergeVars['state'], $mergeVars['postal_code'], $mergeVars['phone'], $mergeVars['fax'], $mergeVars['business']); $this->logger->notice('Adding contact status: ' . print_r($contact, true)); $status = $this->getClient()->subscribeContactToList($contact->contactId, $data['list']); $this->logger->notice('Subscription status: ' . print_r($status, true)); /* * API returns empty status if user exists */ if (empty($status)) { if (isset($_POST['already_subscribed_url']) && op_post('already_subscribed_url') !== '') { $_POST['redirect_url'] = op_post('already_subscribed_url'); } else { if (isset($_POST['redirect_url'])) { $action = sprintf(__('<a href="javascript:history.go(-1);">Return to previous page</a> or <a href="%s">continue</a>.', 'optimizepress'), op_post('redirect_url')); } else { $action = __('<a href="javascript:history.go(-1);">Return to previous page.</a>', 'optimizepress'); } op_warning_screen(__('This email is already subscribed...', 'optimizepress'), __('Optin form - Warning', 'optimizepress'), $action); } } return true; } catch (Exception $e) { $this->logger->error('Error ' . $e->getCode() . ': ' . $e->getMessage()); return false; } } else { $this->logger->alert('Mandatory information not present [list and/or email address]'); wp_die('Mandatory information not present [list and/or email address].'); return false; } }
/** * @see OptimizePress_Modules_Email_ProviderInterface::subscribe() */ public function subscribe($data) { $this->logger->info('Subscribing user: '******'email'])) { $params['fields'] = $this->prepareMergeVars(); $params['fields']['E-Mail'] = $data['email']; if (isset($data['list']) && !empty($data['list'])) { $params['sequences'] = array($data['list']); } try { $status = $this->getClient()->add_contact($params); $this->logger->notice('Subscription status: ' . print_r($status, true)); } catch (Exception $e) { $this->logger->error('Error ' . $e->getCode() . ': ' . $e->getMessage()); } return true; } else { $this->logger->alert('Mandatory information not present [email address]'); wp_die('Mandatory information not present [email address].'); } }
/** * @see OptimizePress_Modules_Email_ProviderInterface::subscribe() */ public function subscribe($data) { $this->logger->info('Subscribing user: '******'list']) && isset($data['email'])) { $result = $this->getClient()->listSubscribe(op_post('first_name'), op_post('last_name'), $data['email'], $data['list'], op_post('phone'), op_post('fax'), $this->prepareMergeVars($data['list'])); /* * Returns status "Subscribed" whether user subscribed or not !!! */ $this->logger->notice('Subscription status: ' . print_r($result->status, true)); return true; } else { $this->logger->alert('Mandatory information not present [list and/or email address]'); wp_die('Mandatory information not present [list and/or email address].'); return false; } }
/** * @see OptimizePress_Modules_Email_ProviderInterface::subscribe() */ public function subscribe($data) { $this->logger->info('Subscribing user: '******'list']) && isset($data['email'])) { $fields = $this->prepareMergeVars($data['list']); $status = $this->getClient()->import_single_member($data['email'], $fields, array($data['list'])); $this->logger->notice('Subscription status: ' . print_r($status, true)); if (!isset($status->added) || $status->added != 1) { // No extra info then the one provided by debug } return true; } else { $this->logger->alert('Mandatory information not present [list and/or email address]'); wp_die('Mandatory information not present [list and/or email address].'); } }
/** * @see OptimizePress_Modules_Email_ProviderInterface::subscribe() */ public function subscribe($data) { $this->logger->info('Subscribing user: '******'list']) && isset($data['email'])) { $params = $this->prepareMergeVars(); try { $status = $this->getClient()->addContact($data['list'], op_post('name') !== false ? op_post('name') : 'Friend', $data['email'], 'standard', 0, $params); $this->logger->notice('Subscription status: ' . print_r($status, true)); } catch (Exception $e) { $this->logger->error('Error ' . $e->getCode() . ': ' . $e->getMessage()); } return true; } else { $this->logger->alert('Mandatory information not present [list and/or email address]'); wp_die('Mandatory information not present [list and/or email address ].'); } }
/** * @see OptimizePress_Modules_Email_ProviderInterface::subscribe() */ public function subscribe($data) { $this->logger->info('Subscribing user: '******'list']) && isset($data['email'])) { $webinarKey = substr($data['list'], 1); unset($data['list']); try { $status = $this->getClient()->createRegistrant($webinarKey, $data); $this->logger->notice('Subscription status: ' . print_r($status, true)); } catch (Exception $e) { $this->logger->error('Error ' . $e->getCode() . ': ' . $e->getMessage()); } return true; } else { $this->logger->alert('Mandatory information not present [list and/or email address]'); wp_die('Mandatory information not present [webinar and/or email address].'); } }
/** * @see OptimizePress_Modules_Email_ProviderInterface::subscribe() */ public function subscribe($data) { if (isset($data['list']) && isset($data['email'])) { $mergeVars = $this->prepareMergeVars(); try { $contact = $this->getClient()->addContact($data['email'], 'normal', $mergeVars['prefix'], $mergeVars['name'], $mergeVars['last_name'], $mergeVars['sufix'], $mergeVars['street'], $mergeVars['street2'], $mergeVars['city'], $mergeVars['state'], $mergeVars['postal_code'], $mergeVars['phone'], $mergeVars['fax'], $mergeVars['business']); $this->logger->notice('Adding contact status: ' . print_r($contact, true)); $status = $this->getClient()->subscribeContactToList($contact->contactId, $data['list']); $this->logger->notice('Subscription status: ' . print_r($status, true)); return true; } catch (Exception $e) { $this->logger->error('Error ' . $e->getCode() . ': ' . $e->getMessage()); return true; } } else { $this->logger->alert('Mandatory information not present [list and/or email address]'); wp_die('Mandatory information not present [list and/or email address].'); } }
/** * @see OptimizePress_Modules_Email_ProviderInterface::subscribe() */ public function subscribe($data) { $this->logger->info('Subscribing user: '******'list']) && isset($data['email'])) { $mergeVars = $this->prepareMergeVars($data['list']); $subscriber = array('EmailAddress' => $data['email'], 'Name' => op_post('Name') ? op_post('Name') : '-', 'CustomFields' => $mergeVars, 'Resubscribe' => true, 'RestartSubscriptionBasedAutoresponders' => true); $status = $this->getSubscribersClient($data['list'])->add($subscriber); $this->logger->notice('Subscription status: ' . print_r($status, true)); /* * Displays error */ if (!$status->was_successful()) { $this->logger->error('Error ' . $status->response->Code . ': ' . $status->response->Message); } return true; } else { $this->logger->alert('Mandatory information not present [list and/or email address]'); wp_die('Mandatory information not present [list and/or email address].'); } }
/** * @see OptimizePress_Modules_Email_ProviderInterface::subscribe() */ public function subscribe($data) { $this->logger->info('Subscribing user (Mailchimp): ' . print_r($data, true)); if (isset($data['list']) && isset($data['email'])) { $mergeVars = $this->prepareMergeVars($data['list']); $doubleOptin = op_post('double_optin') === 'Y' ? true : false; $welcomeEmail = op_post('welcome_email') === 'Y' ? true : false; $updateExisting = apply_filters('op_mailchimp_update_existing_subscriber', false); if ($doubleOptin) { $welcomeEmail = false; } $status = $this->getClient()->listSubscribe($data['list'], $data['email'], $mergeVars, 'html', $doubleOptin, $updateExisting, true, $welcomeEmail); $this->logger->notice('Subscription status (Mailchimp): ' . print_r($status, true)); /* * Displays error */ if (false === $status) { $this->logger->error('Error ' . $this->getClient()->errorCode . ' (Mailchimp): ' . $this->getClient()->errorMessage); if ($this->getClient()->errorCode == 214) { // Hijack redirect URL if user is already subscribed and already_subscribed_url param is defined if (isset($_POST['already_subscribed_url']) && op_post('already_subscribed_url') !== '') { $_POST['redirect_url'] = op_post('already_subscribed_url'); } else { if (isset($_POST['redirect_url'])) { $action = sprintf(__('<a href="javascript:history.go(-1);">Return to previous page</a> or <a href="%s">continue</a>.', 'optimizepress'), op_post('redirect_url')); } else { $action = __('<a href="javascript:history.go(-1);">Return to previous page.</a>', 'optimizepress'); } op_warning_screen(__('This email is already subscribed...', 'optimizepress'), __('Optin form - Warning', 'optimizepress'), $action); } } return false; } $this->logger->info('User added to list (Mailchimp)'); return true; } else { $this->logger->alert('Mandatory information not present [list and/or email address]'); wp_die('Mandatory information not present [list and/or email address].'); return false; } }