本文整理汇总了PHP中add_existing_user_to_blog函数的典型用法代码示例。如果您正苦于以下问题:PHP add_existing_user_to_blog函数的具体用法?PHP add_existing_user_to_blog怎么用?PHP add_existing_user_to_blog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_existing_user_to_blog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: include_professors
function include_professors()
{
$admin_id = get_user_id_from_string(get_blog_option($current_blog->blog_id, 'admin_email'));
$blog_major = get_user_major();
//get_the_user_major($admin_id);
//var_dump($blog_major);
if ($GLOBALS['blog_id'] != 1) {
//makes sure it's not the root blog
$args = array('blog_id' => 1, 'role' => 'professor');
$professors = get_users($args);
//get all profs from root blog
//loop through profs, add as user if same major, delete if different major
foreach ($professors as $professor) {
$prof_major = get_the_user_major($professor->ID);
//var_dump($prof_major);
if ($prof_major == $blog_major) {
$current_role = get_the_user_role($professor);
if ($current_role != 'Administrator') {
$result = add_existing_user_to_blog(array('user_id' => $professor->ID, 'role' => 'professor'));
}
} else {
$result = remove_user_from_blog($professor->ID, $current_blog->blog_id);
}
}
}
//end if
}
示例2: check_blog_user
/**
* if existing user was not added to the current blog - add him
* @global type $blog_id
* @param type $user
* @return bool
*/
protected function check_blog_user($user)
{
global $blog_id;
$result = true;
if (is_network_admin()) {
if (!array_key_exists($blog_id, get_blogs_of_user($user->ID))) {
$result = add_existing_user_to_blog(array('user_id' => $user->ID, 'role' => 'subscriber'));
}
}
return $result;
}
示例3: authenticate
function authenticate($user, $username, $password)
{
// If previous authentication succeeded, respect that
if (is_a($user, 'WP_User')) {
return $user;
}
// Get the user's WP account
$user = get_user_by('login', $username);
// Find out if the user is a super admin on multisite else an admin
$super_admin = $user ? is_super_admin($user->ID) : false;
if (empty($username) || empty($password)) {
$error = new WP_Error();
if (empty($username)) {
$error->add('empty_username', __('<strong>ERROR</strong>: The username field is empty.'));
}
if (empty($password)) {
$error->add('empty_password', __('<strong>ERROR</strong>: The password field is empty.'));
}
return $error;
}
// If high security mode is enabled and user isn't a super admin.
if (str_true($this->get_setting('high_security')) && !$super_admin) {
// remove default WP authentication hook
remove_filter('authenticate', 'wp_authenticate_username_password', 20, 3);
}
// Sweet, let's try to authenticate our user and pass against LDAP
$auth_result = $this->ldap_auth($username, $password, $this->get_setting('directory'));
// If LDAP did not authenticate the user.
if (!$auth_result) {
// If high security mode is enabled.
if (str_true($this->get_setting('high_security'))) {
// Prevent the default authentication.
return new WP_Error('invalid_username', __('<strong>Simple LDAP Login</strong>: Simple LDAP Login could not authenticate your credentials. The security settings do not permit trying the WordPress user database as a fallback.'));
}
// If LDAP did not authenticate the user and high security mode is disabled
do_action($this->prefix . 'auth_failure');
return false;
}
//
// If we reach here then we have a valid LDAP user. Now we need to check permissions.
//
// If user does not have the required LDAP groups
if (!$this->user_has_groups($username, $this->get_setting('directory'))) {
return new WP_Error("{$this->prefix}login_error", __('<strong>Simple LDAP Login Error</strong>: Your LDAP credentials are correct, but you are not in an authorized LDAP group.'));
}
// If user does not exist or
if (!$user) {
// If user account creation is disabled.
if (!str_true($this->get_setting('create_users'))) {
// Tell plugins about the failed login.
do_action('wp_login_failed', $username);
// Return error.
return new WP_Error('invalid_username', __('<strong>Simple LDAP Login Error</strong>: LDAP credentials are correct, but there is no matching WordPress user and user creation is not enabled.'));
}
// User account creation is enabled
// Add the user.
$new_user = wp_insert_user($this->get_user_data($username, $this->get_setting('directory')));
// Make sure there wasn't an error adding the user.
if (is_wp_error($new_user)) {
// Tell plugins about the failed login.
do_action('wp_login_failed', $username);
// Return error.
return new WP_Error("{$this->prefix}login_error", __('<strong>Simple LDAP Login Error</strong>: LDAP credentials are correct and user creation is allowed but an error occurred creating the user in WordPress. Actual error: ' . $new_user->get_error_message()));
}
// Successfully created the new user so get the WP_User object.
$user = new WP_User($new_user);
}
// If user is not part of the current site.
if (is_user_member_of_blog($user->ID) === false && is_super_admin($user->ID) === false) {
// Add the user to the current blog.
$added = add_existing_user_to_blog(array('user_id' => $user->ID, 'role' => $this->get_setting('role')));
// Make sure there wasn't an error adding the user.
if (is_wp_error($added)) {
// Tell plugins about the failed login.
do_action('wp_login_failed', $username);
// Return error.
return new WP_Error("{$this->prefix}login_error", __('<strong>Simple LDAP Login Error</strong>: LDAP credentials are correct and user creation is allowed but an error occurred while adding the user to this site. Actual error: ' . $new_user->get_error_message()));
}
}
// Allow filtering of the user.
do_action_ref_array($this->prefix . 'auth_success', array($user));
// We have a valid user.
return $user;
}
示例4: maybe_add_existing_user_to_blog
/**
* Add a new user to a blog by visiting /newbloguser/username/.
*
* This will only work when the user's details are saved as an option
* keyed as 'new_user_x', where 'x' is the username of the user to be
* added, as when a user is invited through the regular WP Add User interface.
*
* @since MU
* @uses add_existing_user_to_blog()
*/
function maybe_add_existing_user_to_blog()
{
if (false === strpos($_SERVER['REQUEST_URI'], '/newbloguser/')) {
return false;
}
$parts = explode('/', $_SERVER['REQUEST_URI']);
$key = array_pop($parts);
if ($key == '') {
$key = array_pop($parts);
}
$details = get_option('new_user_' . $key);
if (!empty($details)) {
delete_option('new_user_' . $key);
}
if (empty($details) || is_wp_error(add_existing_user_to_blog($details))) {
wp_die(sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), site_url()));
}
wp_die(sprintf(__('You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">log in</a> using your username and password.'), site_url(), admin_url()), __('Success'));
}
示例5: cp
/**
* s2Member's PayPal Auto-Return/PDT handler (inner processing routine).
*
* @package s2Member\PayPal
* @since 110720
*
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
*
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
*/
public static function cp($vars = array())
{
extract($vars, EXTR_OVERWRITE | EXTR_REFS);
if (!empty($paypal['txn_type']) && preg_match('/^web_accept$/i', $paypal['txn_type']) && (!empty($paypal['item_number']) && preg_match($GLOBALS['WS_PLUGIN__']['s2member']['c']['membership_item_number_wo_level_regex'], $paypal['item_number'])) && (empty($paypal['payment_status']) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal['payment_status'])) && !empty($paypal['txn_id']) && !empty($paypal['payer_email']) && (!empty($paypal['txn_baid']) || ($paypal['txn_baid'] = $paypal['txn_id'])) && (!empty($paypal['txn_cid']) || ($paypal['txn_cid'] = $paypal['txn_id']))) {
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action('ws_plugin__s2member_during_paypal_return_before_new_ccaps', get_defined_vars());
unset($__refs, $__v);
if (!get_transient($transient_rtn = 's2m_rtn_' . md5('s2member_transient_' . $_paypal_s)) && set_transient($transient_rtn, time(), 31556926 * 10)) {
$paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `web_accept` ) w/ update vars for Capabilities w/o Level.';
list($paypal['level'], $paypal['ccaps'], $paypal['eotper']) = preg_split('/\\:/', $paypal['item_number'], 3);
$paypal['ip'] = preg_match('/ip address/i', $paypal['option_name2']) && $paypal['option_selection2'] ? $paypal['option_selection2'] : '';
$paypal['ip'] = !$paypal['ip'] && preg_match('/^[a-z0-9]+~[0-9\\.]+$/i', $paypal['invoice']) ? preg_replace('/^[a-z0-9]+~/i', '', $paypal['invoice']) : $paypal['ip'];
$paypal['ip'] = !$paypal['ip'] && $_SERVER['REMOTE_ADDR'] ? $_SERVER['REMOTE_ADDR'] : $paypal['ip'];
$paypal['currency'] = strtoupper($paypal['mc_currency']);
// Normalize input currency.
$paypal['currency_symbol'] = c_ws_plugin__s2member_utils_cur::symbol($paypal['currency']);
if (preg_match('/(referenc|associat|updat|upgrad)/i', $paypal['option_name1']) && $paypal['option_selection1']) {
if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal['txn_id'], $paypal['option_selection1'])) && is_object($user = new WP_User($user_id)) && $user->ID) {
if (!$user->has_cap('administrator')) {
$processing = $during = TRUE;
// Yes, we ARE processing this.
$fields = get_user_option('s2member_custom_fields', $user_id);
// These will be needed in the routines below.
$user_reg_ip = get_user_option('s2member_registration_ip', $user_id);
// Original IP during Registration.
$user_reg_ip = $paypal['ip'] = $user_reg_ip ? $user_reg_ip : $paypal['ip'];
// Now merge conditionally.
if (is_multisite() && !is_user_member_of_blog($user_id)) {
add_existing_user_to_blog(array('user_id' => $user_id, 'role' => get_option('default_role')));
$user = new WP_User($user_id);
}
if ($paypal['ccaps'] && preg_match('/^-all/', str_replace('+', '', $paypal['ccaps']))) {
foreach ($user->allcaps as $cap => $cap_enabled) {
if (preg_match('/^access_s2member_ccap_/', $cap)) {
$user->remove_cap($ccap = $cap);
}
}
}
if ($paypal['ccaps'] && preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $paypal['ccaps']))) {
foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $paypal['ccaps']))) as $ccap) {
if (strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap))))) {
$user->add_cap('access_s2member_ccap_' . $ccap);
}
}
}
if (!get_user_option('s2member_registration_ip', $user_id)) {
update_user_option($user_id, 's2member_registration_ip', $paypal['ip']);
}
$paypal['s2member_log'][] = 's2Member Custom Capabilities updated w/ advanced update routines.';
setcookie('s2member_tracking', $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($paypal['txn_id']), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie('s2member_tracking', $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_tracking'] = $s2member_tracking);
$paypal['s2member_log'][] = 'Transient Tracking Cookie set on ( `web_accept` ) w/ update vars for Capabilities w/o Level.';
if ($processing && ($code = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ccap_tracking_codes']) && is_array($cv = preg_split('/\\|/', $paypal['custom']))) {
if (($code = preg_replace('/%%cv([0-9]+)%%/ei', 'trim(@$cv[$1])', $code)) && ($code = preg_replace('/%%(?:subscr|txn)_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $code))) {
if (($code = preg_replace('/%%(?:subscr|txn)_baid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_baid']), $code)) && ($code = preg_replace('/%%(?:subscr|txn)_cid%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_cid']), $code))) {
if (($code = preg_replace('/%%currency%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency']), $code)) && ($code = preg_replace('/%%currency_symbol%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['currency_symbol']), $code))) {
if (($code = preg_replace('/%%amount%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['mc_gross']), $code)) && ($code = preg_replace('/%%txn_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['txn_id']), $code))) {
if (($code = preg_replace('/%%item_number%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_number']), $code)) && ($code = preg_replace('/%%item_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['item_name']), $code))) {
if (($code = preg_replace('/%%first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['first_name']), $code)) && ($code = preg_replace('/%%last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['last_name']), $code))) {
if ($code = preg_replace('/%%full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($paypal['first_name'] . ' ' . $paypal['last_name'])), $code)) {
if ($code = preg_replace('/%%payer_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($paypal['payer_email']), $code)) {
if (($code = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->first_name), $code)) && ($code = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->last_name), $code))) {
if ($code = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(trim($user->first_name . ' ' . $user->last_name)), $code)) {
if ($code = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->user_email), $code)) {
if ($code = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user->user_login), $code)) {
if ($code = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_reg_ip), $code)) {
if ($code = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $code)) {
if (is_array($fields) && !empty($fields)) {
foreach ($fields as $var => $val) {
if (!($code = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $code))) {
break;
}
}
}
if ($code = trim(preg_replace('/%%(.+?)%%/i', '', $code))) {
$paypal['s2member_log'][] = 'Storing Payment Tracking Codes into a Transient Queue. These will be processed on-site.';
set_transient('s2m_' . md5('s2member_transient_ccap_tracking_codes_' . $paypal['txn_id']), $code, 43200);
}
}
}
}
}
}
}
}
}
}
}
}
//.........这里部分代码省略.........
示例6: custom_adduser
/**
* Adds existing user without email confirmation.
*
* @access public
*/
public function custom_adduser()
{
global $wpdb;
check_admin_referer('add-user', '_wpnonce_add-user');
$user_details = null;
if (false !== strpos($_REQUEST['email'], '@')) {
$user_details = get_user_by('email', $_REQUEST['email']);
} else {
if (is_super_admin()) {
$user_details = get_user_by('login', $_REQUEST['email']);
} else {
wp_redirect(add_query_arg(array('update' => 'enter_email'), 'user-new.php'));
die;
}
}
if (!$user_details) {
wp_redirect(add_query_arg(array('update' => 'does_not_exist'), 'user-new.php'));
die;
}
if (!current_user_can('promote_user', $user_details->ID)) {
wp_die(__('Cheatin’ uh?'));
}
// Adding an existing user to this blog
$new_user_email = $user_details->user_email;
$redirect = 'user-new.php';
$username = $user_details->user_login;
$user_id = $user_details->ID;
add_existing_user_to_blog(array('user_id' => $user_id, 'role' => $_REQUEST['role']));
$redirect = add_query_arg(array('update' => 'addnoconfirmation'), 'user-new.php');
wp_redirect($redirect);
die;
}
示例7: import_users
//.........这里部分代码省略.........
$errors[] = "Line #" . $line . ". Network. The Username and/or Email (<code>" . esc_html($user_login) . "</code> / <code>" . esc_html($user_email) . "</code>) are in conflict w/ Network rules.";
}
} else {
$errors[] = "Line #" . $line . ". Conflicting. The Username (<code>" . esc_html($user_login) . "</code>), already exists.";
}
} else {
$errors[] = "Line #" . $line . ". Conflicting. The Email address (<code>" . esc_html($user_email) . "</code>), already exists.";
}
} else {
$errors[] = "Line #" . $line . ". Invalid Username (<code>" . esc_html($user_login) . "</code>). Lowercase alphanumerics are required.";
}
} else {
$errors[] = "Line #" . $line . ". Missing Username; please try again.";
}
// We have two separate errors for Usernames. This provides clarity.
} else {
$errors[] = "Line #" . $line . ". Missing or invalid Email address (<code>" . esc_html($user_email) . "</code>); please try again.";
}
} else {
$errors[] = "Line #" . $line . ". User ID# <code>" . $ID . "</code> cannot be updated to an Administrator. Bypassing this line for security.";
}
} else {
$errors[] = "Line #" . $line . ". User ID# <code>" . $ID . "</code> belongs to an Administrator. Bypassing this line for security.";
}
} else {
$errors[] = "Line #" . $line . ". User ID# <code>" . $ID . "</code> does NOT belong to an existing User on this site.";
}
} else {
$errors[] = "Line #" . $line . ". User ID# <code>" . $ID . "</code> does NOT belong to an existing User.";
}
} else {
if (is_multisite() && ($user_id = c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog($user_login, $user_email)) && !is_super_admin($user_id)) {
if (strtolower($role) !== "administrator") {
if (add_existing_user_to_blog(array("user_id" => $user_id, "role" => $role))) {
if (is_object($user = new WP_User($user_id)) && $user->ID) {
update_user_option($user_id, "s2member_custom", $custom);
update_user_option($user_id, "s2member_subscr_id", $subscr_id);
update_user_option($user_id, "s2member_subscr_gateway", $subscr_gateway);
update_user_option($user_id, "s2member_auto_eot_time", $auto_eot_time);
update_user_option($user_id, "s2member_paid_registration_times", $paid_registration_times);
update_user_option($user_id, "s2member_last_payment_time", $last_payment_time);
update_user_option($user_id, "s2member_custom_fields", $custom_fields);
foreach ($user->allcaps as $cap => $cap_enabled) {
if (preg_match("/^access_s2member_ccap_/", $cap)) {
$user->remove_cap($ccap = $cap);
}
}
if ($custom_capabilities && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $custom_capabilities))) {
foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $custom_capabilities))) as $ccap) {
if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) {
$user->add_cap("access_s2member_ccap_" . $ccap);
}
}
}
$imported = $imported + 1;
} else {
$errors[] = "Line #" . $line . ". Unknown object error, please try again.";
}
} else {
$errors[] = "Line #" . $line . ". Unknown User/site addition error, please try again.";
}
} else {
$errors[] = "Line #" . $line . ". Role cannot be Administrator. Bypassing this line for security.";
}
} else {
if (strtolower($role) !== "administrator") {
示例8: ms_create_existing_user
/**
* For Multisite Networks, this function is used to add a User to an existing Blog; and to simulate ``wp_create_user()`` behavior.
*
* The ``$user_id`` value will be returned by this function, just like ``wp_create_user()`` does.
* This function will fire the Hook `user_register`.
*
* @package s2Member\Registrations
* @since 3.5
*
* @param string $user_login Expects the User's Username.
* @param string $user_email Expects the User's Email Address.
* @param string $user_pass Expects the User's plain text Password.
* @param int|string $user_id Optional. A numeric WordPress User ID.
* If unspecified, a lookup is performed with ``$user_login`` and ``$user_email``.
*
* @return int|false Returns numeric ``$user_id`` on success, else false on failure.
*/
public static function ms_create_existing_user($user_login = '', $user_email = '', $user_pass = '', $user_id = '')
{
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action('ws_plugin__s2member_before_ms_create_existing_user', get_defined_vars());
unset($__refs, $__v);
// Housekeeping.
if (is_multisite()) {
if (($user_id || ($user_id = c_ws_plugin__s2member_utils_users::ms_user_login_email_exists_but_not_on_blog($user_login, $user_email))) && $user_pass) {
$role = get_option('default_role');
// Use default Role.
add_existing_user_to_blog(array('user_id' => $user_id, 'role' => $role));
// Add User.
wp_update_user(wp_slash(array('ID' => $user_id, 'user_pass' => $user_pass)));
// Update to ``$user_pass``.
do_action('ws_plugin__s2member_during_ms_create_existing_user', get_defined_vars());
do_action('user_register', $user_id);
// So s2Member knows a User is registering.
return apply_filters('ws_plugin__s2member_ms_create_existing_user', $user_id, get_defined_vars());
}
}
return apply_filters('ws_plugin__s2member_ms_create_existing_user', FALSE, get_defined_vars());
}
示例9: eMember_wp_create_user
function eMember_wp_create_user($user_name, $password, $email, $more = array())
{
$more['role'] = isset($more['role']) ? $more['role'] : 'subscriber';
if (eMember_is_multisite_install()) {
//MS install
global $blog_id;
if ($wp_user_id = email_exists($email)) {
// if user exists then just add him to current blog.
add_existing_user_to_blog(array('user_id' => $wp_user_id, 'role' => 'subscriber'));
return $wp_user_id;
}
$wp_user_id = wpmu_create_user($user_name, $password, $email);
if (is_wp_error($wp_user_id)) {
eMember_log_debug("Error: " . $wp_user_id->get_error_message(), true);
return $wp_user_id;
}
eMember_log_debug("Creating WP User using Multi site API. User ID: " . $wp_user_id . " Blog ID: " . $blog_id, true);
$more['ID'] = $wp_user_id;
wp_update_user($more);
update_wp_user_Role($wp_user_id, $more['role']);
$role = $more['role'];
if (add_user_to_blog($blog_id, $wp_user_id, $role)) {
//Add user to the current blog
eMember_log_debug("WP MS user successfully added to blog ID: " . $blog_id, true);
} else {
eMember_log_debug("WP MS user addition to blog failed!", false);
}
return $wp_user_id;
} else {
//Single site install
$wp_user_id = wp_create_user($user_name, $password, $email);
if (is_wp_error($wp_user_id)) {
eMember_log_debug("Error: " . $wp_user_id->get_error_message(), true);
return $wp_user_id;
}
$more['ID'] = $wp_user_id;
wp_update_user($more);
update_wp_user_Role($wp_user_id, $more['role']);
eMember_log_debug("Creating WP User using single site API. User ID: " . $wp_user_id, true);
return $wp_user_id;
}
}
示例10: cp
/**
* s2Member's PayPal IPN handler (inner processing routine).
*
* @package s2Member\PayPal
* @since 110720
*
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_notify_in::paypal_notify()}.
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
*
* @todo Optimize with ``empty()`` and ``isset()``.
*/
public static function cp($vars = array())
{
extract($vars);
// Extract all vars passed in from: ``c_ws_plugin__s2member_paypal_notify_in::paypal_notify()``.
if (!empty($paypal["txn_type"]) && preg_match("/^subscr_modify\$/i", $paypal["txn_type"]) && (!empty($paypal["item_number"]) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"])) && !empty($paypal["subscr_id"]) && !empty($paypal["payer_email"])) {
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action("ws_plugin__s2member_during_paypal_notify_before_subscr_modify", get_defined_vars());
unset($__refs, $__v);
if (!get_transient($transient_ipn = "s2m_ipn_" . md5("s2member_transient_" . $_paypal_s)) && set_transient($transient_ipn, time(), 31556926 * 10)) {
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `subscr_modify` ).";
list($paypal["level"], $paypal["ccaps"]) = preg_split("/\\:/", $paypal["item_number"], 2);
$paypal["ip"] = preg_match("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"] ? $paypal["option_selection2"] : "";
$paypal["ip"] = !$paypal["ip"] && preg_match("/^[a-z0-9]+~[0-9\\.]+\$/i", $paypal["invoice"]) ? preg_replace("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
$paypal["period1"] = preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["period1"] : "0 D";
// Defaults to "0 D" (zero days).
$paypal["mc_amount1"] = strlen($paypal["mc_amount1"]) && $paypal["mc_amount1"] > 0 ? $paypal["mc_amount1"] : "0.00";
// "0.00".
$paypal["initial_term"] = preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["period1"] : "0 D";
// Defaults to "0 D" (zero days).
$paypal["initial"] = strlen($paypal["mc_amount1"]) && preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
$paypal["regular"] = $paypal["mc_amount3"];
// This is the Regular Payment Amount that is charged to the Customer. Always required by PayPal.
$paypal["regular_term"] = $paypal["period3"];
// This is just set to keep a standard; this way both initial_term & regular_term are available.
$paypal["recurring"] = $paypal["recurring"] ? $paypal["mc_amount3"] : "0";
// If non-recurring, this should be zero, otherwise Regular.
$ipn_signup_vars = $paypal;
unset($ipn_signup_vars["s2member_log"]);
// Create array of IPN signup vars w/o s2member_log.
if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal["subscr_id"])) && is_object($user = new WP_User($user_id)) && $user->ID) {
if (!$user->has_cap("administrator")) {
$processing = $modifying = $during = true;
// Yes, we ARE processing this.
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action("ws_plugin__s2member_during_paypal_notify_during_before_subscr_modify", get_defined_vars());
do_action("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars(), "ipn-upgrade-downgrade", "modification", "s2member_level" . $paypal["level"]);
unset($__refs, $__v);
$fields = get_user_option("s2member_custom_fields", $user_id);
// These will be needed in the routines below.
$user_reg_ip = get_user_option("s2member_registration_ip", $user_id);
// Original IP during Registration.
$user_reg_ip = $paypal["ip"] = $user_reg_ip ? $user_reg_ip : $paypal["ip"];
// Now merge conditionally.
if (is_multisite() && !is_user_member_of_blog($user_id)) {
add_existing_user_to_blog(array("user_id" => $user_id, "role" => "s2member_level" . $paypal["level"]));
$user = new WP_User($user_id);
}
$current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
if ($current_role !== "s2member_level" . $paypal["level"]) {
// Only if we need to.
$user->set_role("s2member_level" . $paypal["level"]);
}
// (upgrade/downgrade)
if ($paypal["ccaps"] && preg_match("/^-all/", str_replace("+", "", $paypal["ccaps"]))) {
foreach ($user->allcaps as $cap => $cap_enabled) {
if (preg_match("/^access_s2member_ccap_/", $cap)) {
$user->remove_cap($ccap = $cap);
}
}
}
if ($paypal["ccaps"] && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $paypal["ccaps"]))) {
foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $paypal["ccaps"]))) as $ccap) {
if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) {
$user->add_cap("access_s2member_ccap_" . $ccap);
}
}
}
update_user_option($user_id, "s2member_subscr_gateway", $paypal["subscr_gateway"]);
update_user_option($user_id, "s2member_subscr_id", $paypal["subscr_id"]);
update_user_option($user_id, "s2member_custom", $paypal["custom"]);
if (!get_user_option("s2member_registration_ip", $user_id)) {
update_user_option($user_id, "s2member_registration_ip", $paypal["ip"]);
}
update_user_option($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars);
delete_user_option($user_id, "s2member_file_download_access_log");
delete_user_option($user_id, "s2member_auto_eot_time");
$pr_times = get_user_option("s2member_paid_registration_times", $user_id);
$pr_times["level"] = !$pr_times["level"] ? time() : $pr_times["level"];
// Preserves existing.
$pr_times["level" . $paypal["level"]] = !$pr_times["level" . $paypal["level"]] ? time() : $pr_times["level" . $paypal["level"]];
update_user_option($user_id, "s2member_paid_registration_times", $pr_times);
// Update now.
c_ws_plugin__s2member_user_notes::clear_user_note_lines($user_id, "/^Demoted by s2Member\\:/");
c_ws_plugin__s2member_user_notes::clear_user_note_lines($user_id, "/^Paid Subscr\\. ID @ time of demotion\\:/");
$paypal["s2member_log"][] = "s2Member Level/Capabilities updated on Subscription modification.";
//.........这里部分代码省略.........
示例11: maybe_add_existing_user_to_blog
function maybe_add_existing_user_to_blog()
{
if (false === strpos($_SERVER['REQUEST_URI'], '/newbloguser/')) {
return false;
}
$parts = explode('/', $_SERVER['REQUEST_URI']);
$key = array_pop($parts);
if ($key == '') {
$key = array_pop($parts);
}
$details = get_option("new_user_" . $key);
add_existing_user_to_blog($details);
delete_option('new_user_' . $key);
wp_die(sprintf(__('You have been added to this blog. Please visit the <a href="%s">homepage</a> or <a href="%s">login</a> using your username and password.'), site_url(), admin_url()));
}
示例12: cp
/**
* s2Member's PayPal Auto-Return/PDT handler (inner processing routine).
*
* @package s2Member\PayPal
* @since 110720
*
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
*
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
*/
public static function cp($vars = array())
{
extract($vars, EXTR_OVERWRITE | EXTR_REFS);
if (!empty($paypal['txn_type']) && preg_match('/^subscr_modify$/i', $paypal['txn_type']) && (!empty($paypal['item_number']) && preg_match($GLOBALS['WS_PLUGIN__']['s2member']['c']['membership_item_number_w_level_regex'], $paypal['item_number'])) && !empty($paypal['subscr_id']) && (!empty($paypal['subscr_baid']) || ($paypal['subscr_baid'] = $paypal['subscr_id'])) && (!empty($paypal['subscr_cid']) || ($paypal['subscr_cid'] = $paypal['subscr_id']))) {
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action('ws_plugin__s2member_during_paypal_return_before_subscr_modify', get_defined_vars());
unset($__refs, $__v);
if (!get_transient($transient_rtn = 's2m_rtn_' . md5('s2member_transient_' . $_paypal_s)) && set_transient($transient_rtn, time(), 31556926 * 10)) {
$paypal['s2member_log'][] = 's2Member `txn_type` identified as ( `subscr_modify` ), a Subscription Modification.';
list($paypal['level'], $paypal['ccaps']) = preg_split('/\\:/', $paypal['item_number'], 2);
$paypal['ip'] = preg_match('/ip address/i', $paypal['option_name2']) && $paypal['option_selection2'] ? $paypal['option_selection2'] : '';
$paypal['ip'] = !$paypal['ip'] && preg_match('/^[a-z0-9]+~[0-9\\.]+$/i', $paypal['invoice']) ? preg_replace('/^[a-z0-9]+~/i', '', $paypal['invoice']) : $paypal['ip'];
$paypal['ip'] = !$paypal['ip'] && $_SERVER['REMOTE_ADDR'] ? $_SERVER['REMOTE_ADDR'] : $paypal['ip'];
$paypal['period1'] = preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['period1'] : '0 D';
// Defaults to '0 D' (zero days).
$paypal['mc_amount1'] = strlen($paypal['mc_amount1']) && $paypal['mc_amount1'] > 0 ? $paypal['mc_amount1'] : '0.00';
if (preg_match('/^web_accept$/i', $paypal['txn_type'])) {
$paypal['period3'] = !empty($paypal['eotper']) ? $paypal['eotper'] : '1 L';
// 1 Lifetime.
$paypal['mc_amount3'] = $paypal['mc_gross'];
// The 'Buy Now' amount is the full gross.
}
$paypal['initial_term'] = preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['period1'] : '0 D';
// Defaults to '0 D' (zero days).
$paypal['initial'] = strlen($paypal['mc_amount1']) && preg_match('/^[1-9]/', $paypal['period1']) ? $paypal['mc_amount1'] : $paypal['mc_amount3'];
$paypal['regular'] = $paypal['mc_amount3'];
// This is the Regular Payment Amount that is charged to the Customer. Always required by PayPal.
$paypal['regular_term'] = $paypal['period3'];
// This is just set to keep a standard; this way both initial_term & regular_term are available.
$paypal['recurring'] = $paypal['recurring'] ? $paypal['mc_amount3'] : '0';
// If non-recurring, this should be zero, otherwise Regular.
$paypal['currency'] = strtoupper($paypal['mc_currency']);
// Normalize input currency.
$paypal['currency_symbol'] = c_ws_plugin__s2member_utils_cur::symbol($paypal['currency']);
$ipn_signup_vars = $paypal;
// Copy of PayPal vars; used as IPN signup vars.
unset($ipn_signup_vars['s2member_log']);
// Create array of wouldbe IPN signup vars w/o s2member_log.
if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal['subscr_id'])) && is_object($user = new WP_User($user_id)) && $user->ID) {
if (!$user->has_cap('administrator')) {
$processing = $modifying = $during = TRUE;
// Yes, we ARE processing this.
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action('ws_plugin__s2member_during_paypal_return_during_before_subscr_modify', get_defined_vars());
do_action('ws_plugin__s2member_during_collective_mods', $user_id, get_defined_vars(), 'rtn-upgrade-downgrade', 'modification', 's2member_level' . $paypal['level']);
unset($__refs, $__v);
$fields = get_user_option('s2member_custom_fields', $user_id);
// These will be needed in the routines below.
$user_reg_ip = get_user_option('s2member_registration_ip', $user_id);
// Original IP during Registration.
$user_reg_ip = $paypal['ip'] = $user_reg_ip ? $user_reg_ip : $paypal['ip'];
// Now merge conditionally.
if (is_multisite() && !is_user_member_of_blog($user_id)) {
add_existing_user_to_blog(array('user_id' => $user_id, 'role' => 's2member_level' . $paypal['level']));
$user = new WP_User($user_id);
// Now update the $user object we're using.
}
$current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
if ($current_role !== 's2member_level' . $paypal['level']) {
$user->set_role('s2member_level' . $paypal['level']);
}
// Upgrade/downgrade.
if ($paypal['ccaps'] && preg_match('/^-all/', str_replace('+', '', $paypal['ccaps']))) {
foreach ($user->allcaps as $cap => $cap_enabled) {
if (preg_match('/^access_s2member_ccap_/', $cap)) {
$user->remove_cap($ccap = $cap);
}
}
}
if ($paypal['ccaps'] && preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $paypal['ccaps']))) {
foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $paypal['ccaps']))) as $ccap) {
if (strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap))))) {
$user->add_cap('access_s2member_ccap_' . $ccap);
}
}
}
update_user_option($user_id, 's2member_subscr_gateway', $paypal['subscr_gateway']);
update_user_option($user_id, 's2member_subscr_id', $paypal['subscr_id']);
update_user_option($user_id, 's2member_subscr_baid', $paypal['subscr_baid']);
update_user_option($user_id, 's2member_subscr_cid', $paypal['subscr_cid']);
update_user_option($user_id, 's2member_custom', $paypal['custom']);
if (!get_user_option('s2member_registration_ip', $user_id)) {
update_user_option($user_id, 's2member_registration_ip', $paypal['ip']);
}
update_user_option($user_id, 's2member_ipn_signup_vars', $ipn_signup_vars);
delete_user_option($user_id, 's2member_file_download_access_log');
//.........这里部分代码省略.........
示例13: amuRegisterUser
function amuRegisterUser()
{
global $wpdb;
$validateEmail = get_option('amu_validatemail');
//verify user_login and email are unique and exist
if (username_exists($this->user_login)) {
$newid = __('Error: a user with this user_login already exists. This user was not registered.', 'amulang');
} else {
if ($this->user_email == '') {
$newid = __('Error: an email address for the user', 'amulang') . ' ' . $this->user_login . ' ' . __('was not provided. This user was not registered.', 'amulang');
} else {
if (email_exists($this->user_email)) {
$newid = __('Error: a user with the user_email address', 'amulang') . ' ' . $this->user_email . ' ' . __('already exists. This user was not registered.', 'amulang');
} else {
if ($validateEmail == 'yes' && !is_email($this->user_email)) {
$newid = __('Error: The user_email provided', 'amulang') . ' ' . $this->user_email . ' ' . __('was not valid. This user was not registered.', 'amulang');
//passes all checks, create new user
} else {
$addnewuser = wp_create_user($this->user_login, $this->user_pass, $this->user_email);
$wp_user_object = new WP_User($this->user_login);
//set user role
if ($this->role !== '') {
if (is_multisite()) {
add_existing_user_to_blog(array('user_id' => $wp_user_object->ID, 'role' => $this->role));
} else {
$wp_user_object->set_role($this->role);
}
}
//set response as new user id
$newid = $wp_user_object->ID;
//kill the user object
unset($wp_user_object);
}
}
}
}
//return message
return $newid;
}
示例14: thatcamp_registrations_process_user
/**
* Processes a WP user when adding/updating a registration record. Only
* should be used if we're creating users with approved registrations.
*
* @param integer|null The User ID
* @param array The array of user information.
* @param $registrationId
* @return integer The User ID
**/
function thatcamp_registrations_process_user($registrationId = null, $role = 'author')
{
global $wpdb;
/**
* If the Registration ID is set, it means we already have a registration
* record! Booyah. We'll use the user_id and application_info colums from
* that record to process the user.
*/
if ($registration = thatcamp_registrations_get_registration_by_id($registrationId)) {
$userInfo = maybe_unserialize($registration->applicant_info);
$userId = $registration->user_id ? $registration->user_id : email_exists($registration->applicant_email);
// If we have a valid a User ID, we're dealing with an existing user.
if ($userId) {
// Don't allow Administrators to be demoted. See #24
$wp_user = new WP_User($userId);
if (!is_a($wp_user, 'WP_User') || !in_array('administrator', $wp_user->roles)) {
if (is_multisite()) {
add_existing_user_to_blog(array('user_id' => $userId, 'role' => $role));
} else {
$wp_user->set_role($role);
}
thatcamp_registrations_existing_user_welcome_email($userId);
}
} else {
$randomPassword = wp_generate_password(12, false);
$userEmail = $registration->applicant_email;
// Get a sanitized and unique username
$uarray = split('@', $userEmail);
$userName = sanitize_user($uarray[0], true);
// Use strict to get rid of nastiness
$unique_user_name = apply_filters('pre_user_login', $userName);
// Guarantee unique usernames
while (username_exists($unique_user_name)) {
$append = isset($append) ? $append + 1 : 1;
$unique_user_name = $userName . $append;
}
$userInfo['user_login'] = $unique_user_name;
$userInfo['user_email'] = $userEmail;
$userInfo['user_pass'] = $randomPassword;
$userId = wp_insert_user($userInfo);
if (is_multisite()) {
add_user_to_blog($wpdb->blogid, $userId, $role);
} else {
$wp_user = new WP_User($userId);
$wp_user->set_role($role);
}
thatcamp_registrations_update_user_data($userId, $userInfo);
wp_new_user_notification($userId, $randomPassword);
}
}
return $userId;
}
示例15: cp
/**
* s2Member's PayPal Auto-Return/PDT handler (inner processing routine).
*
* @package s2Member\PayPal
* @since 110720
*
* @param array $vars Required. An array of defined variables passed by {@link s2Member\PayPal\c_ws_plugin__s2member_paypal_return_in::paypal_return()}.
* @return array|bool The original ``$paypal`` array passed in (extracted) from ``$vars``, or false when conditions do NOT apply.
*
* @todo Optimize with ``empty()`` and ``isset()``.
*/
public static function cp($vars = array())
{
extract($vars);
if (!empty($paypal["txn_type"]) && preg_match("/^(web_accept|subscr_signup|subscr_payment)\$/i", $paypal["txn_type"]) && (!empty($paypal["item_number"]) && preg_match($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $paypal["item_number"])) && (!empty($paypal["subscr_id"]) || !empty($paypal["txn_id"]) && ($paypal["subscr_id"] = $paypal["txn_id"])) && (empty($paypal["payment_status"]) || empty($payment_status_issues) || !preg_match($payment_status_issues, $paypal["payment_status"]))) {
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action("ws_plugin__s2member_during_paypal_return_before_subscr_signup", get_defined_vars());
unset($__refs, $__v);
if (!get_transient($transient_rtn = "s2m_rtn_" . md5("s2member_transient_" . $_paypal_s)) && set_transient($transient_rtn, time(), 31556926 * 10)) {
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ).";
list($paypal["level"], $paypal["ccaps"], $paypal["eotper"]) = preg_split("/\\:/", $paypal["item_number"], 3);
$paypal["ip"] = preg_match("/ip address/i", $paypal["option_name2"]) && $paypal["option_selection2"] ? $paypal["option_selection2"] : "";
$paypal["ip"] = !$paypal["ip"] && preg_match("/^[a-z0-9]+~[0-9\\.]+\$/i", $paypal["invoice"]) ? preg_replace("/^[a-z0-9]+~/i", "", $paypal["invoice"]) : $paypal["ip"];
$paypal["ip"] = !$paypal["ip"] && $_SERVER["REMOTE_ADDR"] ? $_SERVER["REMOTE_ADDR"] : $paypal["ip"];
if (preg_match("/^subscr_payment\$/i", $paypal["txn_type"]) && !empty($_GET["s2member_paypal_return_tra"]) && (($tra = c_ws_plugin__s2member_utils_encryption::decrypt(trim(stripslashes($_GET["s2member_paypal_return_tra"])))) && is_array($tra = maybe_unserialize($tra))) && (count($tra) === 11 && isset($tra["ta"], $tra["tp"], $tra["tt"], $tra["ra"], $tra["rp"], $tra["rt"], $tra["rr"], $tra["rrt"], $tra["rra"], $tra["invoice"], $tra["checksum"])) && $tra["invoice"] === $paypal["invoice"] && $tra["checksum"] === md5($paypal["invoice"] . $paypal["ip"] . $paypal["item_number"])) {
$tracking_properties = true;
$paypal["period1"] = $tra["rr"] !== "BN" && $tra["tp"] ? $tra["tp"] . " " . $tra["tt"] : "0 D";
$paypal["mc_amount1"] = $tra["rr"] !== "BN" && $tra["tp"] ? number_format($tra["ta"], 2, ".", "") : "0.00";
$paypal["period3"] = $tra["rp"] . " " . $tra["rt"];
$paypal["mc_amount3"] = $tra["ra"];
$paypal["recurring"] = $tra["rr"] === "1" ? "1" : "0";
$paypal["initial_term"] = preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["period1"] : "0 D";
$paypal["initial"] = strlen($paypal["mc_amount1"]) && preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
$paypal["regular"] = $paypal["mc_amount3"];
$paypal["regular_term"] = $paypal["period3"];
$paypal["recurring"] = $paypal["recurring"] ? $paypal["mc_amount3"] : "0";
$ipn_signup_vars = $paypal;
/* Create array of wouldbe IPN signup vars w/o s2member_log. */
unset($ipn_signup_vars["s2member_log"]);
} else {
if (preg_match("/^(web_accept|subscr_signup)\$/i", $paypal["txn_type"])) {
$tracking_properties = true;
$paypal["period1"] = preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["period1"] : "0 D";
$paypal["mc_amount1"] = strlen($paypal["mc_amount1"]) && $paypal["mc_amount1"] > 0 ? $paypal["mc_amount1"] : "0.00";
if (preg_match("/^web_accept\$/i", $paypal["txn_type"])) {
$paypal["period3"] = $paypal["eotper"] ? $paypal["eotper"] : "1 L";
$paypal["mc_amount3"] = $paypal["mc_gross"];
}
$paypal["initial_term"] = preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["period1"] : "0 D";
$paypal["initial"] = strlen($paypal["mc_amount1"]) && preg_match("/^[1-9]/", $paypal["period1"]) ? $paypal["mc_amount1"] : $paypal["mc_amount3"];
$paypal["regular"] = $paypal["mc_amount3"];
$paypal["regular_term"] = $paypal["period3"];
$paypal["recurring"] = $paypal["recurring"] ? $paypal["mc_amount3"] : "0";
$ipn_signup_vars = $paypal;
/* Create array of wouldbe IPN signup vars w/o s2member_log. */
unset($ipn_signup_vars["s2member_log"]);
}
}
/*
New Subscription with advanced update vars (option_name1, option_selection1)? Used in Subscr. Modifications.
*/
if (preg_match("/(referenc|associat|updat|upgrad)/i", $paypal["option_name1"]) && $paypal["option_selection1"]) {
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action("ws_plugin__s2member_during_paypal_return_before_subscr_signup_w_update_vars", get_defined_vars());
unset($__refs, $__v);
$paypal["s2member_log"][] = "s2Member `txn_type` identified as ( `web_accept|subscr_signup|subscr_payment` ) w/ update vars.";
if (($user_id = c_ws_plugin__s2member_utils_users::get_user_id_with($paypal["subscr_id"], $paypal["option_selection1"])) && is_object($user = new WP_User($user_id)) && $user->ID) {
if (!$user->has_cap("administrator")) {
$processing = $modifying = $during = true;
foreach (array_keys(get_defined_vars()) as $__v) {
$__refs[$__v] =& ${$__v};
}
do_action("ws_plugin__s2member_during_paypal_return_during_before_subscr_signup_w_update_vars", get_defined_vars());
do_action("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars(), "rtn-upgrade-downgrade", "modification", "s2member_level" . $paypal["level"]);
unset($__refs, $__v);
$fields = get_user_option("s2member_custom_fields", $user_id);
$user_reg_ip = get_user_option("s2member_registration_ip", $user_id);
$user_reg_ip = $paypal["ip"] = $user_reg_ip ? $user_reg_ip : $paypal["ip"];
if (is_multisite() && !is_user_member_of_blog($user_id)) {
add_existing_user_to_blog(array("user_id" => $user_id, "role" => "s2member_level" . $paypal["level"]));
$user = new WP_User($user_id);
}
$current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
if ($current_role !== "s2member_level" . $paypal["level"]) {
$user->set_role("s2member_level" . $paypal["level"]);
}
if ($paypal["ccaps"] && preg_match("/^-all/", str_replace("+", "", $paypal["ccaps"]))) {
foreach ($user->allcaps as $cap => $cap_enabled) {
if (preg_match("/^access_s2member_ccap_/", $cap)) {
$user->remove_cap($ccap = $cap);
}
}
}
if ($paypal["ccaps"] && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $paypal["ccaps"]))) {
foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $paypal["ccaps"]))) as $ccap) {
if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) {
//.........这里部分代码省略.........