本文整理汇总了PHP中SendPress_Data::subscribe_user方法的典型用法代码示例。如果您正苦于以下问题:PHP SendPress_Data::subscribe_user方法的具体用法?PHP SendPress_Data::subscribe_user怎么用?PHP SendPress_Data::subscribe_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SendPress_Data
的用法示例。
在下文中一共展示了SendPress_Data::subscribe_user方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
function save()
{
$post_options = array('list', 'email', 'firstname', 'lastname', 'status');
$user_info = array();
foreach ($post_options as $opt) {
$user_info[$opt] = isset($_POST['sp_' . $opt]) ? $_POST['sp_' . $opt] : false;
}
$valid_user = array();
//foreach()
if (isset($user_info['list'])) {
if (!is_array($user_info['list'])) {
$user_info['list'] = array($user_info['list']);
}
if (isset($user_info['status'])) {
$valid_user['status'] = $user_info['status'];
} else {
$valid_user['status'] = 2;
}
$data_error = false;
if (isset($user_info['email']) && is_email($user_info['email'])) {
$valid_user['email'] = $user_info['email'];
} else {
$data_error = __('Invalid Email', 'sendpress');
}
if (isset($user_info['firstname'])) {
$valid_user['firstname'] = $user_info['firstname'];
} else {
$valid_user['firstname'] = '';
}
if (isset($user_info['lastname'])) {
$valid_user['lastname'] = $user_info['lastname'];
} else {
$valid_user['lastname'] = '';
}
$status = false;
if ($data_error == false) {
$list = implode(",", $user_info['list']);
$custom = apply_filters('sendpress_subscribe_to_list_custom_fields', array(), $_POST);
$status = SendPress_Data::subscribe_user($list, $valid_user['email'], $valid_user['firstname'], $valid_user['lastname'], $valid_user['status'], $custom);
if ($status == false) {
$data_error = __('Problem with subscribing user.', 'sendpress');
} else {
$data_error = __('Thanks for subscribing.', 'sendpress');
}
}
}
$this->message = $data_error;
}
示例2: snp_popup_submit
//.........这里部分代码省略.........
$list = $account->loadFromUrl('/accounts/' . $account->id . '/lists/' . $aw_list);
$subscriber = array('email' => $_POST['email'], 'ip' => $_SERVER['REMOTE_ADDR']);
if (!empty($_POST['name'])) {
$subscriber['name'] = $_POST['name'];
}
if (count($cf_data) > 0) {
$subscriber['custom_fields'] = $cf_data;
}
$r = $list->subscribers->create($subscriber);
$Done = 1;
} catch (AWeberException $e) {
$api_error_msg = $e->getMessage();
}
}
} elseif (snp_get_option('ml_manager') == 'wysija' && class_exists('WYSIJA')) {
$ml_wy_list = $POPUP_META['snp_ml_wy_list'][0];
if (!$ml_wy_list) {
$ml_wy_list = snp_get_option('ml_wy_list');
}
$userData = array('email' => $_POST['email'], 'firstname' => $names['first'], 'lastname' => $names['last']);
$data = array('user' => $userData, 'user_list' => array('list_ids' => array($ml_wy_list)));
$userHelper =& WYSIJA::get('user', 'helper');
if ($userHelper->addSubscriber($data)) {
$Done = 1;
} else {
$api_error_msg = 'MailPoet Problem!';
}
} elseif (snp_get_option('ml_manager') == 'sendpress') {
$ml_sp_list = $POPUP_META['snp_ml_sp_list'][0];
if (!$ml_sp_list) {
$ml_sp_list = snp_get_option('ml_sp_list');
}
try {
SendPress_Data::subscribe_user($ml_sp_list, $_POST['email'], $names['first'], $names['last'], 2);
$Done = 1;
} catch (Exception $e) {
$api_error_msg = 'SendPress Problem!';
}
} elseif (snp_get_option('ml_manager') == 'mymail') {
$userdata = array('firstname' => $names['first'], 'lastname' => $names['last']);
$ml_mm_list = $POPUP_META['snp_ml_mm_list'][0];
if (!$ml_mm_list) {
$ml_mm_list = snp_get_option('ml_mm_list');
}
$lists = array($ml_mm_list);
if (function_exists('mymail')) {
$entry = $userdata;
$entry['email'] = $_POST['email'];
$double_optin = snp_get_option('ml_mm_double_optin');
if ($double_optin == 1) {
$entry['status'] = 0;
} else {
$entry['status'] = 1;
}
if (count($cf_data) > 0) {
foreach ($cf_data as $k => $v) {
$entry[$k] = $v;
}
}
$subscriber_id = mymail('subscribers')->add($entry, true);
if (!is_wp_error($subscriber_id)) {
$success = mymail('subscribers')->assign_lists($subscriber_id, $lists, false);
}
if ($success) {
$Done = 1;
} else {
示例3: html
function html()
{
if (isset($_POST['sp-shortcode']) && strpos($_POST['sp-shortcode'], 'SC-') !== false) {
$cls = str_replace('-', '_', trim($_POST['sp-shortcode']));
call_user_func(array('SendPress_' . $cls, "form_post"), '');
} else {
$post_options = array('list', 'email', 'firstname', 'lastname', 'return', 'status');
$user_info = array();
foreach ($post_options as $opt) {
$user_info[$opt] = isset($_POST['sp_' . $opt]) ? $_POST['sp_' . $opt] : false;
}
$valid_user = array();
//foreach()
if (isset($user_info['list'])) {
if (!is_array($user_info['list'])) {
$user_info['list'] = array($user_info['list']);
}
$data_error = false;
if ($user_info['status'] !== false) {
$valid_user['status'] = $user_info['status'];
} else {
$valid_user['status'] = 2;
}
if ($user_info['email'] !== false && is_email($user_info['email'])) {
$valid_user['email'] = $user_info['email'];
} else {
$data_error = __('Invalid Email', 'sendpress');
}
if ($user_info['firstname'] !== false) {
$valid_user['firstname'] = $user_info['firstname'];
} else {
$valid_user['firstname'] = '';
}
if ($user_info['lastname'] !== false) {
$valid_user['lastname'] = $user_info['lastname'];
} else {
$valid_user['lastname'] = '';
}
$status = false;
if ($data_error == false) {
$list = implode(",", $user_info['list']);
$custom = apply_filters('sendpress_subscribe_to_list_custom_fields', array(), $_POST);
$status = SendPress_Data::subscribe_user($list, $valid_user['email'], $valid_user['firstname'], $valid_user['lastname'], $valid_user['status'], $custom);
if ($status == false) {
$data_error = __('Problem with subscribing user.', 'sendpress');
}
}
$post_responce = get_post_meta($user_info['list'][0], 'post-page', true);
if ($post_responce == false) {
$post_responce = 'default';
}
if ($user_info['return'] != false) {
$post_responce = $user_info['return'];
}
$optin = SendPress_Option::is_double_optin();
if (isset($_POST['redirect']) && $_POST['redirect'] > 0) {
$plink = get_permalink($_POST['redirect']);
if ($plink != "") {
wp_redirect(esc_url_raw($plink));
exit;
}
}
switch ($post_responce) {
case "json":
//Respond to post with json data
if ($status == false || $data_error != false) {
// { success: true/false, list: listid , name: listname, optin: true/false }
$info = array("success" => false, "error" => $data_error, "list" => $user_info['list']);
}
if ($status) {
$info = array("success" => true, "error" => $data_error, "list" => $user_info['list'], "optin" => $optin, "email" => $valid_user['email']);
}
$encoded = json_encode($info);
header('Content-type: application/json');
exit($encoded);
break;
case "custom":
$post_redirect = get_post_meta($user_info['list'][0], 'post-page-id', true);
if ($post_redirect == false) {
$post_redirect = site_url();
} else {
$plink = get_permalink($post_redirect);
if ($plink != "") {
wp_safe_redirect(esc_url_raw($plink));
exit;
}
}
wp_redirect(esc_url_raw($post_redirect));
exit;
break;
case "redirect":
$post_redirect = get_post_meta($user_info['list'][0], 'post-redirect', true);
if ($post_redirect == false) {
$post_redirect = site_url();
}
wp_redirect(esc_url_raw($post_redirect));
exit;
break;
default:
$this->default_page($status, $data_error);
//.........这里部分代码省略.........
示例4: subscribe_to_list
function subscribe_to_list()
{
global $wpdb;
// Create the response array
$response = array('success' => false);
if ($_POST) {
// get the credit card details submitted by the form
$first = isset($_POST['first']) ? $_POST['first'] : '';
$last = isset($_POST['last']) ? $_POST['last'] : '';
$email = isset($_POST['email']) ? $_POST['email'] : '';
$listid = isset($_POST['listid']) ? $_POST['listid'] : '';
$custom = apply_filters('sendpress_subscribe_to_list_custom_fields', array(), $_POST);
$success = SendPress_Data::subscribe_user($listid, $email, $first, $last, 2, $custom);
if (false !== $success) {
$response['success'] = true;
$response['exists'] = $success['already'];
} else {
$response['error'] = __('User was not subscribed to the list.', 'sendpress');
}
}
// Add additional processing here
if ($response['success']) {
// Succeess
} else {
// Failed
}
// Serialize the response back as JSON
echo json_encode($response);
die;
}
示例5: header
header('HTTP/1.0 403 Forbidden');
die;
}
/**
*
* SENDPRESS FRONT END ACTIONS
*
* see @sendpress class line 101
* Handles saving data and other user actions.
*
**/
global $sendpress_show_thanks, $sendpress_signup_error;
switch ($this->_current_action) {
case 'signup-user':
$sendpress_show_thanks = false;
$sendpress_signup_error = "There was an error signing up, please try again.";
$s = new SendPress();
$first = isset($_POST['first']) ? $_POST['first'] : '';
$last = isset($_POST['last']) ? $_POST['last'] : '';
$email = isset($_POST['email']) ? $_POST['email'] : '';
$listid = isset($_POST['list']) ? $_POST['list'] : '';
$custom = apply_filters('sendpress_subscribe_to_list_custom_fields', array(), $_POST);
$success = SendPress_Data::subscribe_user($listid, $email, $first, $last, 2, $custom);
//need to do stuff with the form on the page
//var_dump($success);
if ((bool) $success) {
$sendpress_signup_error = "";
$sendpress_show_thanks = true;
}
break;
}
示例6: subscribe_user
function subscribe_user($listid, $email, $first, $last)
{
_deprecated_function(__FUNCTION__, '0.8.9', 'SendPress_Data::subscribe_user()');
SendPress_Data::subscribe_user($listid, $email, $first, $last);
}