public function Remove_password_nag_if_browserid_registration()
 {
     global $user_ID;
     $registered_with_browserid = get_user_meta($user_ID, 'browserid_registration', true);
     if ($registered_with_browserid === true) {
         delete_user_setting('default_password_nag', $user_ID);
         update_user_option($user_ID, 'default_password_nag', false, true);
     }
 }
Exemple #2
0
 function wp_new_user_notification($user_id, $plaintext_pass = '')
 {
     global $wpdb, $mySabre;
     $user = new WP_User($user_id);
     $user_login = stripslashes($user->user_login);
     $user_email = stripslashes($user->user_email);
     $message = sprintf(__('New user registration on your site %s:', 'sabre'), get_option('blogname')) . "\r\n\r\n";
     $message .= sprintf(__('Username: %s', 'sabre'), $user_login) . "\r\n\r\n";
     $message .= sprintf(__('E-mail: %s', 'sabre'), $user_email) . "\r\n";
     $sabre_opt = $mySabre->get_option('sabre_opt');
     $mail_from = "From: ";
     $mail_from .= (!empty($sabre_opt['mail_from_name']) ? $sabre_opt['mail_from_name'] : get_option('blogname')) . " <";
     $mail_from .= (!empty($sabre_opt['mail_from_mail']) ? $sabre_opt['mail_from_mail'] : get_option('admin_email')) . ">";
     @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration', 'sabre'), get_option('blogname')), $message, $mail_from);
     if (empty($plaintext_pass)) {
         return;
     }
     if ($sabre_opt['user_pwd'] == 'true') {
         $plaintext_pass = $_POST['user_pwd1'];
         wp_set_password($plaintext_pass, $user_id);
         delete_user_setting('default_password_nag', $user_id);
         update_user_option($user_id, 'default_password_nag', false, true);
     }
     $message = sprintf(__('Thank you for registering on %s', 'sabre'), get_option('blogname')) . "\r\n\r\n";
     $message .= sprintf(__('Username: %s', 'sabre'), $user_login) . "\r\n";
     if ($sabre_opt['user_pwd'] == 'true') {
         $message .= __('Use the password defined during your registration', 'sabre') . "\r\n\r\n";
     } else {
         $message .= sprintf(__('Password: %s', 'sabre'), $plaintext_pass) . "\r\n\r\n";
     }
     if ($sabre_opt['enable_confirm'] == 'user') {
         $message .= sprintf(__ngettext('You must confirm your registration within %s day by following the link below', 'You must confirm your registration within %s days by following the link below', $sabre_opt['period'], 'sabre'), $sabre_opt['period']) . "\r\n\r\n";
         $message .= get_option('siteurl') . "/wp-login.php?sabre_confirm=" . md5($_POST['sabre_id']) . "\r\n";
     } elseif ($sabre_opt['enable_confirm'] == 'admin') {
         $message .= __('Your registration has to be validated by the administrator before you can sign on the site. You will be advised by e-mail upon completion.', 'sabre') . "\r\n\r\n";
         $message .= get_option('siteurl') . "/wp-login.php\r\n";
     } else {
         $message .= get_option('siteurl') . "/wp-login.php\r\n";
     }
     wp_mail($user_email, sprintf(__('[%s] - Your registration information', 'sabre'), get_option('blogname')), $message, $mail_from);
 }
 /**
  * Handles login redirections.
  *
  * @package s2Member\Login_Redirects
  * @since 3.5
  *
  * @attaches-to ``add_action('wp_login');``
  *
  * @param string  $username Expects Username.
  * @param WP_User $user Expects a WP_User object instance.
  *
  * @return null Or exits script execution after a redirection takes place.
  */
 public static function login_redirect($username = '', $user = NULL)
 {
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__s2member_before_login_redirect', get_defined_vars());
     unset($__refs, $__v);
     // Housekeeping.
     $ci = $GLOBALS['WS_PLUGIN__']['s2member']['o']['ruris_case_sensitive'] ? '' : 'i';
     if (is_string($username) && $username && is_object($user) && !empty($user->ID) && ($user_id = $user->ID)) {
         update_user_option($user_id, 's2member_last_login_time', time());
         $logins = (int) get_user_option('s2member_login_counter', $user_id) + 1;
         update_user_option($user_id, 's2member_login_counter', $logins);
         if (!get_user_option('s2member_registration_ip', $user_id)) {
             update_user_option($user_id, 's2member_registration_ip', $_SERVER['REMOTE_ADDR']);
         }
         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_password']) {
             delete_user_setting('default_password_nag');
             update_user_option($user_id, 'default_password_nag', FALSE, TRUE);
         }
         $ok = TRUE;
         // Initialize IP restriction being OK here. This is for filters.
         if ($username !== 'demo' && !is_super_admin($user_id) && !apply_filters('ws_plugin__s2member_disable_login_ip_restrictions', $user->has_cap('edit_posts') ? TRUE : FALSE, get_defined_vars())) {
             $ok = c_ws_plugin__s2member_ip_restrictions::ip_restrictions_ok($_SERVER['REMOTE_ADDR'], strtolower($username));
         }
         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_always_http']) {
             // Alter value of `redirect_to`?
             if (!empty($_REQUEST['redirect_to']) && is_string($_REQUEST['redirect_to']) && strpos($_REQUEST['redirect_to'], 'wp-admin') === FALSE) {
                 $_REQUEST['redirect_to'] = preg_replace('/^https\\:\\/\\//i', 'http://', $_REQUEST['redirect_to']);
                 if (stripos($_REQUEST['redirect_to'], 'http://') !== 0) {
                     $redirect_uri = $_REQUEST['redirect_to'];
                     // e.g., `/path/with/?query=args`
                     $home_path = trim((string) @parse_url(home_url('/'), PHP_URL_PATH), '/');
                     $http_home_base = trim(preg_replace('/\\/' . preg_quote($home_path, '/') . '\\/$/' . $ci, '', home_url('/', 'http')), '/');
                     $_REQUEST['redirect_to'] = $http_home_base . '/' . ltrim($redirect_uri, '/');
                 }
             }
         }
         if ($redirect = apply_filters('ws_plugin__s2member_login_redirect', $user->has_cap('edit_posts') ? FALSE : TRUE, get_defined_vars())) {
             $obey_redirect_to = apply_filters('ws_plugin__s2member_obey_login_redirect_to', TRUE, get_defined_vars());
             if ($obey_redirect_to && (empty($_REQUEST['redirect_to']) || !is_string($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] === admin_url() || preg_match('/^\\/?wp-admin\\/?$/' . $ci, $_REQUEST['redirect_to']))) {
                 $obey_redirect_to = FALSE;
             } else {
                 if ($obey_redirect_to && !empty($_REQUEST['redirect_to_automatic']) && is_string($redirect)) {
                     $obey_redirect_to = FALSE;
                 }
             }
             // Do not obey automatic redirects when a custom redirection filter applies.
             // ↑ NOTE: this will apply to s2Member Pro's One-Time-Offers (Upon Login) also.
             if (!$obey_redirect_to) {
                 foreach (array_keys(get_defined_vars()) as $__v) {
                     $__refs[$__v] =& ${$__v};
                 }
                 do_action('ws_plugin__s2member_during_login_redirect', get_defined_vars());
                 unset($__refs, $__v);
                 // Housekeeping.
                 $is_lwp = FALSE;
                 // Initialize LWP detection flag.
                 if ($redirect && is_string($redirect)) {
                     $redirect = $redirect;
                 } else {
                     if ($login_redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url($user)) {
                         $is_lwp = TRUE;
                         // Flag as being a hard-coded LWP URL in this case.
                         $redirect = $login_redirection_url;
                         // Special redirection URL.
                     } else {
                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page']) {
                             $is_lwp = TRUE;
                             // Flag as being a hard-coded LWP URL in this case.
                             $redirect = get_page_link($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page']);
                         } else {
                             $redirect = home_url('/');
                         }
                     }
                 }
                 // Default to the home page.
                 if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_always_http']) {
                     $redirect = preg_replace('/^https\\:\\/\\//i', 'http://', $redirect);
                     if (stripos($redirect, 'http://') !== 0) {
                         $redirect_uri = $redirect;
                         // e.g., `/path/with/?query=args`
                         $home_path = trim((string) @parse_url(home_url('/'), PHP_URL_PATH), '/');
                         $http_home_base = trim(preg_replace('/\\/' . preg_quote($home_path, '/') . '\\/$/' . $ci, '', home_url('/', 'http')), '/');
                         $redirect = $http_home_base . '/' . ltrim($redirect_uri, '/');
                     }
                 }
                 if ($is_lwp) {
                     // Allow offsite redirection?
                     wp_redirect($redirect);
                 } else {
                     wp_safe_redirect($redirect);
                 }
                 // Default behavior.
                 exit;
                 // Stop here; redirecting now.
             }
         }
     }
     do_action('ws_plugin__s2member_after_login_redirect', get_defined_vars());
 }
Exemple #4
0
function default_password_nag_edit_user($user_ID, $old_data)
{
    if (!get_user_option('default_password_nag', $user_ID)) {
        //Short circuit it.
        return;
    }
    $new_data = get_userdata($user_ID);
    if ($new_data->user_pass != $old_data->user_pass) {
        //Remove the nag if the password has been changed.
        delete_user_setting('default_password_nag', $user_ID);
        update_user_option($user_ID, 'default_password_nag', false, true);
    }
}
function wp_menu_unfold() {
	if ( isset($_GET['unfoldmenu']) ) {
		delete_user_setting('mfold');
		wp_redirect( remove_query_arg( 'unfoldmenu', stripslashes($_SERVER['REQUEST_URI']) ) );
	 	exit;
	}
}
function xt_register_remove_default_password_nag()
{
    global $user_ID;
    delete_user_setting('default_password_nag', $user_ID);
    update_user_option($user_ID, 'default_password_nag', false, true);
}
 /**
  * Handles login redirections.
  *
  * @package s2Member\Login_Redirects
  * @since 3.5
  *
  * @attaches-to ``add_action("wp_login");``
  *
  * @param str $username Expects Username.
  * @param WP_User $user Expects a WP_User object instance.
  * @return null Or exits script execution after a redirection takes place.
  */
 public static function login_redirect($username = FALSE, $user = FALSE)
 {
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_before_login_redirect", get_defined_vars());
     unset($__refs, $__v);
     if (is_string($username) && $username && is_object($user) && !empty($user->ID) && ($user_id = $user->ID)) {
         update_user_option($user_id, "s2member_last_login_time", time());
         if (!get_user_option("s2member_registration_ip", $user_id)) {
             update_user_option($user_id, "s2member_registration_ip", $_SERVER["REMOTE_ADDR"]);
         }
         if (($logins = (int) get_user_option("s2member_login_counter", $user_id) + 1) >= 1 || ($logins = 1)) {
             update_user_option($user_id, "s2member_login_counter", $logins);
         }
         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"]) {
             delete_user_setting("default_password_nag") . update_user_option($user_id, "default_password_nag", false, true);
         }
         $disable_login_ip_restrictions = apply_filters("ws_plugin__s2member_disable_login_ip_restrictions", false, get_defined_vars());
         if (($ok = true) && !is_super_admin($user_id) && $username !== "demo" && !$disable_login_ip_restrictions) {
             $ok = c_ws_plugin__s2member_ip_restrictions::ip_restrictions_ok($_SERVER["REMOTE_ADDR"], $username);
         }
         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_always_http"]) {
             // Alter value of `redirect_to`?
             if (!empty($_REQUEST["redirect_to"]) && is_string($_REQUEST["redirect_to"]) && strpos($_REQUEST["redirect_to"], "wp-admin") === FALSE) {
                 $_REQUEST["redirect_to"] = preg_replace("/^https\\:\\/\\//i", "http://", $_REQUEST["redirect_to"]);
                 if (stripos($_REQUEST["redirect_to"], "http://") !== 0) {
                     // Force an absolute URL in this case.
                     $_REQUEST["redirect_to"] = home_url($_REQUEST["redirect_to"], "http");
                 }
             }
         }
         if ($redirect = apply_filters("ws_plugin__s2member_login_redirect", $user->has_cap("edit_posts") ? false : true, get_defined_vars())) {
             $obey_redirect_to = apply_filters("ws_plugin__s2member_obey_login_redirect_to", true, get_defined_vars());
             if (!$obey_redirect_to || empty($_REQUEST["redirect_to"]) || !is_string($_REQUEST["redirect_to"]) || $_REQUEST["redirect_to"] === admin_url() || preg_match("/^\\/?wp-admin\\/?\$/", $_REQUEST["redirect_to"])) {
                 foreach (array_keys(get_defined_vars()) as $__v) {
                     $__refs[$__v] =& ${$__v};
                 }
                 do_action("ws_plugin__s2member_during_login_redirect", get_defined_vars());
                 unset($__refs, $__v);
                 if ($redirect && is_string($redirect)) {
                     $redirect = $redirect;
                 } else {
                     if ($redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url($user)) {
                         $redirect = $redirection_url;
                     } else {
                         // Else we use the Login Welcome Page configured for s2Member.
                         $redirect = get_page_link($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]);
                     }
                 }
                 if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_always_http"]) {
                     $redirect = preg_replace("/^https\\:\\/\\//i", "http://", $redirect);
                     if (stripos($redirect, "http://") !== 0) {
                         // Force an absolute URL in this case.
                         $redirect = home_url($redirect, "http");
                     }
                 }
                 wp_redirect($redirect) . exit;
             }
         }
     }
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_after_login_redirect", get_defined_vars());
     unset($__refs, $__v);
     return;
 }
 /**
  * Configures all new Users.
  *
  * The Hook `user_register` is also fired by calling:
  * ``c_ws_plugin__s2member_registrations::ms_create_existing_user()`` and/or ``wpmu_create_user()``.
  *
  * This function also receives hand-offs from s2Member's handlers for these two Hooks:
  * `wpmu_activate_user` and `wpmu_activate_blog`.
  *
  * @package s2Member\Registrations
  * @since 3.5
  *
  * @attaches-to ``add_action("user_register");``
  *
  * @param int|str $user_id A numeric WordPress User ID.
  * @param str $password Optional in most cases. A User's plain text Password. If unspecified, attempts are made to collect the plain text Password from other sources.
  * @param array $meta Optional in most cases. Defaults to false. An array of meta data for a User/Member.
  * @return null No return value. Returns `null` in possible every scenario.
  *
  * @todo Impossible to delete cookies when fired inside: `/wp-activate.php`?
  */
 public static function configure_user_registration($user_id = FALSE, $password = FALSE, $meta = FALSE)
 {
     global $wpdb;
     global $pagenow;
     // We need this to detect the current administration page.
     global $current_site, $current_blog;
     // Adds support for Multisite Networking.
     static $email_config, $processed;
     // Static vars prevent duplicate processing.
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_before_configure_user_registration", get_defined_vars());
     unset($__refs, $__v);
     // With Multisite Networking, we need this to run on `user_register` ahead of `wpmu_activate_[user|blog]`.
     if (!isset($email_config) && ($email_config = true)) {
         // Anytime this routine is fired; we configure email.
         c_ws_plugin__s2member_email_configs::email_config();
     }
     // Configures `From:` email header.
     $_p = isset($_POST) ? $_POST : null;
     $rvs = isset($GLOBALS["ws_plugin__s2member_registration_vars"]) ? $GLOBALS["ws_plugin__s2member_registration_vars"] : null;
     if (!$processed) {
         if (is_array($_p) || is_array($meta) || is_array($rvs)) {
             if (!(is_multisite() && is_blog_admin() && $pagenow === "user-new.php" && isset($_p["noconfirmation"]) && is_super_admin() && !is_array($meta))) {
                 if (!(preg_match("/\\/wp-activate\\.php/", $_SERVER["REQUEST_URI"]) && !is_array($meta))) {
                     if (!(c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_activation_page() && !is_array($meta))) {
                         if (!(c_ws_plugin__s2member_utils_conds::pro_is_installed() && c_ws_plugin__s2member_pro_remote_ops::is_remote_op("create_user") && !is_array($rvs))) {
                             if ($user_id && is_object($user = new WP_User($user_id)) && !empty($user->ID) && ($user_id = $user->ID) && ($processed = true)) {
                                 settype($_p, "array") . settype($meta, "array") . settype($rvs, "array");
                                 $_p = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_p));
                                 $meta = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($meta));
                                 $rvs = c_ws_plugin__s2member_utils_strings::trim_deep($rvs);
                                 foreach ($_p as $_key => $_value) {
                                     // Scan ``$_p`` vars; adding `custom_reg_field` keys.
                                     if (preg_match("/^ws_plugin__s2member_user_new_/", $_key)) {
                                         // Look for keys.
                                         if ($_key = str_replace("_user_new_", "_custom_reg_field_", $_key)) {
                                             $_p[$_key] = $_value;
                                         }
                                     }
                                 }
                                 // Add each of these key conversions.
                                 unset($_key, $_value);
                                 if (!is_admin() && (isset($_p["ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway"]) || isset($_p["ws_plugin__s2member_custom_reg_field_s2member_subscr_id"]) || isset($_p["ws_plugin__s2member_custom_reg_field_s2member_custom"]) || isset($_p["ws_plugin__s2member_custom_reg_field_s2member_ccaps"]) || isset($_p["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"]) || isset($_p["ws_plugin__s2member_custom_reg_field_s2member_notes"]))) {
                                     exit(_x("s2Member security violation. You attempted to POST administrative variables that will NOT be trusted in a NON-administrative zone!", "s2member-front", "s2member"));
                                 }
                                 $_pmr = array_merge($_p, $meta, $rvs);
                                 // Merge all of these arrays together now, in this specific order.
                                 unset($_p, $meta, $rvs);
                                 // These variables can all be unset now; we have them all in the ``$_pmr`` array.
                                 $custom_reg_display_name = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_display_name"];
                                 // Can be configured by the site owner.
                                 if (!is_admin() && (!c_ws_plugin__s2member_utils_conds::pro_is_installed() || !c_ws_plugin__s2member_pro_remote_ops::is_remote_op("create_user")) && ($reg_cookies = c_ws_plugin__s2member_register_access::reg_cookies_ok()) && extract($reg_cookies)) {
                                     /* This routine could be processed through `/wp-login.php?action=register`, `/wp-activate.php`, or `/activate` via BuddyPress`.
                                     			This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`.
                                     			If processed through `/wp-activate.php`, it could've originated inside the admin — via `/user-new.php`. */
                                     $processed = "yes";
                                     // Mark this as yes.
                                     $current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
                                     @(list($level, $ccaps, $eotper) = preg_split("/\\:/", $item_number, 3));
                                     $role = "s2member_level" . $level;
                                     // Membership Level.
                                     $email = $user->user_email;
                                     $login = $user->user_login;
                                     $ip = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_registration_ip"];
                                     $ip = !$ip ? $_SERVER["REMOTE_ADDR"] : $ip;
                                     // Else use environment variable.
                                     $cv = preg_split("/\\|/", $custom);
                                     if (!($auto_eot_time = "") && $eotper) {
                                         // If a specific EOT Period is included.
                                         $auto_eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time("", "", "", $eotper);
                                     }
                                     $notes = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_notes"];
                                     $opt_in = !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] ? true : false;
                                     $opt_in = !$opt_in && !empty($_pmr["ws_plugin__s2member_custom_reg_field_opt_in"]) ? true : $opt_in;
                                     if (!($fname = $user->first_name)) {
                                         if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_first_name"])) {
                                             $fname = (string) $_pmr["ws_plugin__s2member_custom_reg_field_first_name"];
                                         }
                                     }
                                     if (!$fname) {
                                         // Also try BuddyPress.
                                         if (!empty($_pmr["field_1"])) {
                                             // BuddyPress?
                                             $fname = trim(preg_replace("/ (.*)\$/", "", (string) $_pmr["field_1"]));
                                         }
                                     }
                                     if (!($lname = $user->last_name)) {
                                         if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_last_name"])) {
                                             $lname = (string) $_pmr["ws_plugin__s2member_custom_reg_field_last_name"];
                                         }
                                     }
                                     if (!$lname) {
                                         // Also try BuddyPress.
                                         if (!empty($_pmr["field_1"]) && preg_match("/^(.+?) (.+)\$/", (string) $_pmr["field_1"])) {
                                             $lname = trim(preg_replace("/^(.+?) (.+)\$/", "\$2", (string) $_pmr["field_1"]));
                                         }
                                     }
                                     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"] && !$fname && $login) {
                                         $fname = trim($login);
                                         $lname = "";
                                     }
                                     // Username and empty Last Name.
                                     $name = trim($fname . " " . $lname);
                                     // Both names.
                                     if (!($pass = $password)) {
                                         // Try s2Member's generator.
                                         if (!empty($GLOBALS["ws_plugin__s2member_generate_password_return"])) {
                                             $pass = (string) $GLOBALS["ws_plugin__s2member_generate_password_return"];
                                         }
                                     }
                                     if (!$pass) {
                                         // Also try BuddyPress Password.
                                         if (!empty($_pmr["signup_password"])) {
                                             // BuddyPress?
                                             $pass = (string) $_pmr["signup_password"];
                                         }
                                     }
                                     if ($pass) {
                                         !headers_sent() ? delete_user_setting("default_password_nag", $user_id) : null;
                                         update_user_option($user_id, "default_password_nag", false, true);
                                     }
                                     update_user_option($user_id, "s2member_registration_ip", $ip);
                                     update_user_option($user_id, "s2member_auto_eot_time", $auto_eot_time);
                                     update_user_option($user_id, "s2member_subscr_gateway", $subscr_gateway);
                                     update_user_option($user_id, "s2member_subscr_id", $subscr_id);
                                     update_user_option($user_id, "s2member_custom", $custom);
                                     update_user_option($user_id, "s2member_notes", $notes);
                                     if (!$user->first_name && $fname) {
                                         update_user_meta($user_id, "first_name", $fname);
                                     }
                                     if (!$user->last_name && $lname) {
                                         update_user_meta($user_id, "last_name", $lname);
                                     }
                                     if (!$user->display_name || $user->display_name === $user->user_login) {
                                         if ($custom_reg_display_name === "full" && $name) {
                                             wp_update_user(array("ID" => $user_id, "display_name" => $name));
                                         } else {
                                             if ($custom_reg_display_name === "first" && $fname) {
                                                 wp_update_user(array("ID" => $user_id, "display_name" => $fname));
                                             } else {
                                                 if ($custom_reg_display_name === "last" && $lname) {
                                                     wp_update_user(array("ID" => $user_id, "display_name" => $lname));
                                                 } else {
                                                     if ($custom_reg_display_name === "login" && $login) {
                                                         wp_update_user(array("ID" => $user_id, "display_name" => $login));
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                     if (is_multisite()) {
                                         if (!is_main_site() && strtotime($user->user_registered) >= strtotime("-10 seconds")) {
                                             remove_user_from_blog($user_id, $current_site->blog_id);
                                         }
                                         // No Main Site Role.
                                         if (!get_user_meta($user_id, "s2member_originating_blog", true)) {
                                             // Recorded yet?
                                             update_user_meta($user_id, "s2member_originating_blog", $current_blog->blog_id);
                                         }
                                     }
                                     if ($current_role !== $role) {
                                         // Only if NOT the current Role.
                                         $user->set_role($role);
                                     }
                                     // s2Member.
                                     if ($ccaps && preg_match("/^-all/", str_replace("+", "", $ccaps))) {
                                         foreach ($user->allcaps as $cap => $cap_enabled) {
                                             if (preg_match("/^access_s2member_ccap_/", $cap)) {
                                                 $user->remove_cap($ccap = $cap);
                                             }
                                         }
                                     }
                                     if ($ccaps && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) {
                                         foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) as $ccap) {
                                             if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) {
                                                 $user->add_cap("access_s2member_ccap_" . $ccap);
                                             }
                                         }
                                     }
                                     if (!($fields = array()) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) {
                                         foreach (json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field) {
                                             $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                                             $field_id_class = preg_replace("/_/", "-", $field_var);
                                             if (isset($_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var])) {
                                                 $fields[$field_var] = $_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var];
                                             }
                                         }
                                     }
                                     unset($field, $field_var, $field_id_class);
                                     // Housekeeping.
                                     if (!empty($fields)) {
                                         // Only if NOT empty.
                                         update_user_option($user_id, "s2member_custom_fields", $fields);
                                     }
                                     if ($level > 0) {
                                         $pr_times = get_user_option("s2member_paid_registration_times", $user_id);
                                         $pr_times["level"] = empty($pr_times["level"]) ? time() : $pr_times["level"];
                                         $pr_times["level" . $level] = empty($pr_times["level" . $level]) ? time() : $pr_times["level" . $level];
                                         update_user_option($user_id, "s2member_paid_registration_times", $pr_times);
                                         // Update now.
                                     }
                                     if (($transient = "s2m_" . md5("s2member_transient_ipn_signup_vars_" . $subscr_id)) && is_array($ipn_signup_vars = get_transient($transient))) {
                                         update_user_option($user_id, "s2member_ipn_signup_vars", $ipn_signup_vars);
                                         // For future reference.
                                         delete_transient($transient);
                                         // This can be deleted now.
                                     }
                                     if (($transient = "s2m_" . md5("s2member_transient_ipn_subscr_payment_" . $subscr_id)) && is_array($subscr_payment = get_transient($transient)) && !empty($subscr_payment["subscr_gateway"])) {
                                         $proxy = array("s2member_paypal_proxy" => stripslashes((string) $subscr_payment["subscr_gateway"]), "s2member_paypal_proxy_verification" => c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
                                         c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1"), array_merge(stripslashes_deep($subscr_payment), $proxy), array("timeout" => 20));
                                         delete_transient($transient);
                                         // This can be deleted now.
                                     }
                                     if (($transient = "s2m_" . md5("s2member_transient_ipn_subscr_eot_" . $subscr_id)) && is_array($subscr_eot = get_transient($transient)) && !empty($subscr_eot["subscr_gateway"])) {
                                         $proxy = array("s2member_paypal_proxy" => stripslashes((string) $subscr_eot["subscr_gateway"]), "s2member_paypal_proxy_verification" => c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
                                         c_ws_plugin__s2member_utils_urls::remote(site_url("/?s2member_paypal_notify=1"), array_merge(stripslashes_deep($subscr_eot), $proxy), array("timeout" => 20));
                                         delete_transient($transient);
                                         // This can be deleted now.
                                     }
                                     if (!headers_sent()) {
                                         // Only if headers are NOT yet sent. Here we establish both Signup and Payment Tracking Cookies.
                                         @setcookie("s2member_tracking", $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($subscr_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie("s2member_tracking", $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE["s2member_tracking"] = $s2member_tracking);
                                     }
                                     foreach (array_keys(get_defined_vars()) as $__v) {
                                         $__refs[$__v] =& ${$__v};
                                     }
                                     do_action("ws_plugin__s2member_during_configure_user_registration_front_side_paid", get_defined_vars());
                                     do_action("ws_plugin__s2member_during_configure_user_registration_front_side", get_defined_vars());
                                     unset($__refs, $__v);
                                 } else {
                                     if (!is_admin() && (!c_ws_plugin__s2member_utils_conds::pro_is_installed() || !c_ws_plugin__s2member_pro_remote_ops::is_remote_op("create_user"))) {
                                         /* This routine could be processed through `/wp-login.php?action=register`, `/wp-activate.php`, or `/activate` via BuddyPress`.
                                         			This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`.
                                         			If processed through `/wp-activate.php`, it could've originated inside the admin, via `/user-new.php`. */
                                         $processed = "yes";
                                         // Mark this as yes.
                                         $current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
                                         $role = "";
                                         // Initialize ``$role`` to an empty string here, before processing.
                                         $role = !$role && ($level = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"]) > 0 ? "s2member_level" . $level : $role;
                                         $role = !$role && ($level = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"]) === "0" ? "subscriber" : $role;
                                         $role = !$role && $current_role ? $current_role : $role;
                                         // Use existing Role?
                                         $role = !$role ? get_option("default_role") : $role;
                                         // Otherwise default.
                                         $level = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"];
                                         $level = !$level && preg_match("/^(administrator|editor|author|contributor)\$/i", $role) ? $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"] : $level;
                                         $level = !$level && preg_match("/^s2member_level[1-9][0-9]*\$/i", $role) ? preg_replace("/^s2member_level/", "", $role) : $level;
                                         $level = !$level && preg_match("/^subscriber\$/i", $role) ? "0" : $level;
                                         $level = !$level ? "0" : $level;
                                         $ccaps = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_ccaps"];
                                         $email = $user->user_email;
                                         $login = $user->user_login;
                                         $ip = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_registration_ip"];
                                         $ip = !$ip ? $_SERVER["REMOTE_ADDR"] : $ip;
                                         // Else use environment variable.
                                         $custom = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_custom"];
                                         $subscr_id = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_id"];
                                         $subscr_gateway = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway"];
                                         $cv = preg_split("/\\|/", (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_custom"]);
                                         $auto_eot_time = ($eot = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"]) ? strtotime($eot) : "";
                                         $notes = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_notes"];
                                         $opt_in = !$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] ? true : false;
                                         $opt_in = !$opt_in && !empty($_pmr["ws_plugin__s2member_custom_reg_field_opt_in"]) ? true : $opt_in;
                                         if (!($fname = $user->first_name)) {
                                             if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_first_name"])) {
                                                 $fname = (string) $_pmr["ws_plugin__s2member_custom_reg_field_first_name"];
                                             }
                                         }
                                         if (!$fname) {
                                             // Also try BuddyPress.
                                             if (!empty($_pmr["field_1"])) {
                                                 // BuddyPress?
                                                 $fname = trim(preg_replace("/ (.*)\$/", "", (string) $_pmr["field_1"]));
                                             }
                                         }
                                         if (!($lname = $user->last_name)) {
                                             if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_last_name"])) {
                                                 $lname = (string) $_pmr["ws_plugin__s2member_custom_reg_field_last_name"];
                                             }
                                         }
                                         if (!$lname) {
                                             // Also try BuddyPress.
                                             if (!empty($_pmr["field_1"]) && preg_match("/^(.+?) (.+)\$/", (string) $_pmr["field_1"])) {
                                                 $lname = trim(preg_replace("/^(.+?) (.+)\$/", "\$2", (string) $_pmr["field_1"]));
                                             }
                                         }
                                         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"] && !$fname && $login) {
                                             $fname = trim($login);
                                             $lname = "";
                                         }
                                         // Username and empty Last Name.
                                         $name = trim($fname . " " . $lname);
                                         // Both names.
                                         if (!($pass = $password)) {
                                             // Try s2Member's generator.
                                             if (!empty($GLOBALS["ws_plugin__s2member_generate_password_return"])) {
                                                 $pass = (string) $GLOBALS["ws_plugin__s2member_generate_password_return"];
                                             }
                                         }
                                         if (!$pass) {
                                             // Also try BuddyPress Password.
                                             if (!empty($_pmr["signup_password"])) {
                                                 // BuddyPress?
                                                 $pass = (string) $_pmr["signup_password"];
                                             }
                                         }
                                         if ($pass) {
                                             !headers_sent() ? delete_user_setting("default_password_nag", $user_id) : null;
                                             update_user_option($user_id, "default_password_nag", false, true);
                                         }
                                         update_user_option($user_id, "s2member_registration_ip", $ip);
                                         update_user_option($user_id, "s2member_auto_eot_time", $auto_eot_time);
                                         update_user_option($user_id, "s2member_subscr_gateway", $subscr_gateway);
                                         update_user_option($user_id, "s2member_subscr_id", $subscr_id);
                                         update_user_option($user_id, "s2member_custom", $custom);
                                         update_user_option($user_id, "s2member_notes", $notes);
                                         if (!$user->first_name && $fname) {
                                             update_user_meta($user_id, "first_name", $fname);
                                         }
                                         if (!$user->last_name && $lname) {
                                             update_user_meta($user_id, "last_name", $lname);
                                         }
                                         if (!$user->display_name || $user->display_name === $user->user_login) {
                                             if ($custom_reg_display_name === "full" && $name) {
                                                 wp_update_user(array("ID" => $user_id, "display_name" => $name));
                                             } else {
                                                 if ($custom_reg_display_name === "first" && $fname) {
                                                     wp_update_user(array("ID" => $user_id, "display_name" => $fname));
                                                 } else {
                                                     if ($custom_reg_display_name === "last" && $lname) {
                                                         wp_update_user(array("ID" => $user_id, "display_name" => $lname));
                                                     } else {
                                                         if ($custom_reg_display_name === "login" && $login) {
                                                             wp_update_user(array("ID" => $user_id, "display_name" => $login));
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                         if (is_multisite()) {
                                             if (!is_main_site() && strtotime($user->user_registered) >= strtotime("-10 seconds")) {
                                                 remove_user_from_blog($user_id, $current_site->blog_id);
                                             }
                                             if (!get_user_meta($user_id, "s2member_originating_blog", true)) {
                                                 update_user_meta($user_id, "s2member_originating_blog", $current_blog->blog_id);
                                             }
                                         }
                                         if ($current_role !== $role) {
                                             // Only if NOT the current Role.
                                             $user->set_role($role);
                                         }
                                         // s2Member.
                                         if ($ccaps && preg_match("/^-all/", str_replace("+", "", $ccaps))) {
                                             foreach ($user->allcaps as $cap => $cap_enabled) {
                                                 if (preg_match("/^access_s2member_ccap_/", $cap)) {
                                                     $user->remove_cap($ccap = $cap);
                                                 }
                                             }
                                         }
                                         if ($ccaps && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) {
                                             foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) as $ccap) {
                                                 if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) {
                                                     $user->add_cap("access_s2member_ccap_" . $ccap);
                                                 }
                                             }
                                         }
                                         if (!($fields = array()) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) {
                                             foreach (json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field) {
                                                 $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                                                 $field_id_class = preg_replace("/_/", "-", $field_var);
                                                 if (isset($_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var])) {
                                                     $fields[$field_var] = $_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var];
                                                 }
                                             }
                                         }
                                         unset($field, $field_var, $field_id_class);
                                         // Housekeeping.
                                         if (!empty($fields)) {
                                             // Only if NOT empty.
                                             update_user_option($user_id, "s2member_custom_fields", $fields);
                                         }
                                         if ($level > 0) {
                                             $pr_times = get_user_option("s2member_paid_registration_times", $user_id);
                                             $pr_times["level"] = empty($pr_times["level"]) ? time() : $pr_times["level"];
                                             $pr_times["level" . $level] = empty($pr_times["level" . $level]) ? time() : $pr_times["level" . $level];
                                             update_user_option($user_id, "s2member_paid_registration_times", $pr_times);
                                             // Update now.
                                         }
                                         foreach (array_keys(get_defined_vars()) as $__v) {
                                             $__refs[$__v] =& ${$__v};
                                         }
                                         do_action("ws_plugin__s2member_during_configure_user_registration_front_side_free", get_defined_vars());
                                         do_action("ws_plugin__s2member_during_configure_user_registration_front_side", get_defined_vars());
                                         unset($__refs, $__v);
                                     } else {
                                         if (is_blog_admin() && $pagenow === "user-new.php" || c_ws_plugin__s2member_utils_conds::pro_is_installed() && c_ws_plugin__s2member_pro_remote_ops::is_remote_op("create_user")) {
                                             // Can only be processed through `/user-new.php` in the Admin panel, or through Remote Op: `create_user`.
                                             $processed = "yes";
                                             // Mark this as yes, to indicate that a routine was processed.
                                             $current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
                                             $role = "";
                                             // Initialize $role to an empty string here, before processing.
                                             $role = !$role && ($level = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"]) > 0 ? "s2member_level" . $level : $role;
                                             $role = !$role && ($level = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"]) === "0" ? "subscriber" : $role;
                                             $role = !$role && $current_role ? $current_role : $role;
                                             // Use existing Role?
                                             $role = !$role ? get_option("default_role") : $role;
                                             // Otherwise default.
                                             $level = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_level"];
                                             $level = !$level && preg_match("/^(administrator|editor|author|contributor)\$/i", $role) ? $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"] : $level;
                                             $level = !$level && preg_match("/^s2member_level[1-9][0-9]*\$/i", $role) ? preg_replace("/^s2member_level/", "", $role) : $level;
                                             $level = !$level && preg_match("/^subscriber\$/i", $role) ? "0" : $level;
                                             $level = !$level ? "0" : $level;
                                             $ccaps = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_ccaps"];
                                             $email = $user->user_email;
                                             $login = $user->user_login;
                                             $ip = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_registration_ip"];
                                             $custom = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_custom"];
                                             $subscr_id = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_id"];
                                             $subscr_gateway = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway"];
                                             $cv = preg_split("/\\|/", (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_custom"]);
                                             $auto_eot_time = ($eot = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"]) ? strtotime($eot) : "";
                                             $notes = (string) @$_pmr["ws_plugin__s2member_custom_reg_field_s2member_notes"];
                                             $opt_in = !empty($_pmr["ws_plugin__s2member_custom_reg_field_opt_in"]) ? true : false;
                                             if (!($fname = $user->first_name)) {
                                                 // `Users -› Add New`.
                                                 if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_first_name"])) {
                                                     $fname = (string) $_pmr["ws_plugin__s2member_custom_reg_field_first_name"];
                                                 }
                                             }
                                             if (!($lname = $user->last_name)) {
                                                 // `Users -› Add New`.
                                                 if (!empty($_pmr["ws_plugin__s2member_custom_reg_field_last_name"])) {
                                                     $lname = (string) $_pmr["ws_plugin__s2member_custom_reg_field_last_name"];
                                                 }
                                             }
                                             if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"] && !$fname && $login) {
                                                 $fname = trim($login);
                                                 $lname = "";
                                             }
                                             // Username and empty Last Name.
                                             $name = trim($fname . " " . $lname);
                                             // Both names.
                                             if (!($pass = $password)) {
                                                 // Try s2Member's generator.
                                                 if (!empty($GLOBALS["ws_plugin__s2member_generate_password_return"])) {
                                                     $pass = (string) $GLOBALS["ws_plugin__s2member_generate_password_return"];
                                                 }
                                             }
                                             if (!$pass) {
                                                 // Also try the `Users -› Add New` form.
                                                 if (!empty($_pmr["pass1"])) {
                                                     // Field in `/user-new.php`.
                                                     $pass = (string) $_pmr["pass1"];
                                                 }
                                             }
                                             if ($pass) {
                                                 !headers_sent() ? delete_user_setting("default_password_nag", $user_id) : null;
                                                 update_user_option($user_id, "default_password_nag", false, true);
                                             }
                                             update_user_option($user_id, "s2member_registration_ip", $ip);
                                             update_user_option($user_id, "s2member_auto_eot_time", $auto_eot_time);
                                             update_user_option($user_id, "s2member_subscr_gateway", $subscr_gateway);
                                             update_user_option($user_id, "s2member_subscr_id", $subscr_id);
                                             update_user_option($user_id, "s2member_custom", $custom);
                                             update_user_option($user_id, "s2member_notes", $notes);
                                             if (!$user->first_name && $fname) {
                                                 update_user_meta($user_id, "first_name", $fname);
                                             }
                                             if (!$user->last_name && $lname) {
                                                 update_user_meta($user_id, "last_name", $lname);
                                             }
                                             if (!$user->display_name || $user->display_name === $user->user_login) {
                                                 if ($custom_reg_display_name === "full" && $name) {
                                                     wp_update_user(array("ID" => $user_id, "display_name" => $name));
                                                 } else {
                                                     if ($custom_reg_display_name === "first" && $fname) {
                                                         wp_update_user(array("ID" => $user_id, "display_name" => $fname));
                                                     } else {
                                                         if ($custom_reg_display_name === "last" && $lname) {
                                                             wp_update_user(array("ID" => $user_id, "display_name" => $lname));
                                                         } else {
                                                             if ($custom_reg_display_name === "login" && $login) {
                                                                 wp_update_user(array("ID" => $user_id, "display_name" => $login));
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                             if (is_multisite()) {
                                                 if (!is_main_site() && strtotime($user->user_registered) >= strtotime("-10 seconds")) {
                                                     remove_user_from_blog($user_id, $current_site->blog_id);
                                                 }
                                                 // No Main Site Role.
                                                 if (!get_user_meta($user_id, "s2member_originating_blog", true)) {
                                                     // Recorded yet?
                                                     update_user_meta($user_id, "s2member_originating_blog", $current_blog->blog_id);
                                                 }
                                             }
                                             if ($current_role !== $role) {
                                                 // Only if NOT the current Role.
                                                 $user->set_role($role);
                                             }
                                             // s2Member.
                                             if ($ccaps && preg_match("/^-all/", str_replace("+", "", $ccaps))) {
                                                 foreach ($user->allcaps as $cap => $cap_enabled) {
                                                     if (preg_match("/^access_s2member_ccap_/", $cap)) {
                                                         $user->remove_cap($ccap = $cap);
                                                     }
                                                 }
                                             }
                                             if ($ccaps && preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) {
                                                 foreach (preg_split("/[\r\n\t\\s;,]+/", preg_replace("/^-all[\r\n\t\\s;,]*/", "", str_replace("+", "", $ccaps))) as $ccap) {
                                                     if (strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) {
                                                         $user->add_cap("access_s2member_ccap_" . $ccap);
                                                     }
                                                 }
                                             }
                                             if (!($fields = array()) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) {
                                                 foreach (json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field) {
                                                     $field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"]));
                                                     $field_id_class = preg_replace("/_/", "-", $field_var);
                                                     if (isset($_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var])) {
                                                         $fields[$field_var] = $_pmr["ws_plugin__s2member_custom_reg_field_" . $field_var];
                                                     }
                                                 }
                                             }
                                             unset($field, $field_var, $field_id_class);
                                             // Housekeeping.
                                             if (!empty($fields)) {
                                                 // Only if NOT empty.
                                                 update_user_option($user_id, "s2member_custom_fields", $fields);
                                             }
                                             if ($level > 0) {
                                                 $pr_times = get_user_option("s2member_paid_registration_times", $user_id);
                                                 $pr_times["level"] = empty($pr_times["level"]) ? time() : $pr_times["level"];
                                                 $pr_times["level" . $level] = empty($pr_times["level" . $level]) ? time() : $pr_times["level" . $level];
                                                 update_user_option($user_id, "s2member_paid_registration_times", $pr_times);
                                                 // Update now.
                                             }
                                             foreach (array_keys(get_defined_vars()) as $__v) {
                                                 $__refs[$__v] =& ${$__v};
                                             }
                                             do_action("ws_plugin__s2member_during_configure_user_registration_admin_side", get_defined_vars());
                                             unset($__refs, $__v);
                                         }
                                     }
                                 }
                                 if ($processed === "yes") {
                                     if ($urls = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_urls"]) {
                                         foreach (preg_split("/[\r\n\t]+/", $urls) as $url) {
                                             // Notify each of the URLs.
                                             if ($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) {
                                                 if ($url = preg_replace("/%%role%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($role)), $url)) {
                                                     if ($url = preg_replace("/%%level%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($level)), $url)) {
                                                         if ($url = preg_replace("/%%ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($ccaps)), $url)) {
                                                             if ($url = preg_replace("/%%auto_eot_time%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($auto_eot_time)), $url)) {
                                                                 if ($url = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($fname)), $url)) {
                                                                     if ($url = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($lname)), $url)) {
                                                                         if ($url = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($name)), $url)) {
                                                                             if ($url = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($email)), $url)) {
                                                                                 if ($url = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($login)), $url)) {
                                                                                     if ($url = preg_replace("/%%user_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($pass)), $url)) {
                                                                                         if ($url = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($ip)), $url)) {
                                                                                             if ($url = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user_id)), $url)) {
                                                                                                 foreach ($fields as $var => $val) {
                                                                                                     // Custom Fields.
                                                                                                     if (!($url = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(maybe_serialize($val))), $url))) {
                                                                                                         break;
                                                                                                     }
                                                                                                 }
                                                                                                 if ($url = trim(preg_replace("/%%(.+?)%%/i", "", $url))) {
                                                                                                     c_ws_plugin__s2member_utils_urls::remote($url);
                                                                                                 }
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                     unset($urls, $url, $var, $val);
                                     // Housekeeping.
                                     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_recipients"]) {
                                         $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status();
                                         c_ws_plugin__s2member_email_configs::email_config_release();
                                         $msg = $sbj = "(s2Member / API Notification Email) - Registration";
                                         $msg .= "\n\n";
                                         // Spacing in the message body.
                                         $msg .= "role: %%role%%\n";
                                         $msg .= "level: %%level%%\n";
                                         $msg .= "ccaps: %%ccaps%%\n";
                                         $msg .= "auto_eot_time: %%auto_eot_time%%\n";
                                         $msg .= "user_first_name: %%user_first_name%%\n";
                                         $msg .= "user_last_name: %%user_last_name%%\n";
                                         $msg .= "user_full_name: %%user_full_name%%\n";
                                         $msg .= "user_email: %%user_email%%\n";
                                         $msg .= "user_login: %%user_login%%\n";
                                         $msg .= "user_pass: %%user_pass%%\n";
                                         $msg .= "user_ip: %%user_ip%%\n";
                                         $msg .= "user_id: %%user_id%%\n";
                                         foreach ($fields as $var => $val) {
                                             $msg .= $var . ": %%" . $var . "%%\n";
                                         }
                                         $msg .= "cv0: %%cv0%%\n";
                                         $msg .= "cv1: %%cv1%%\n";
                                         $msg .= "cv2: %%cv2%%\n";
                                         $msg .= "cv3: %%cv3%%\n";
                                         $msg .= "cv4: %%cv4%%\n";
                                         $msg .= "cv5: %%cv5%%\n";
                                         $msg .= "cv6: %%cv6%%\n";
                                         $msg .= "cv7: %%cv7%%\n";
                                         $msg .= "cv8: %%cv8%%\n";
                                         $msg .= "cv9: %%cv9%%";
                                         if ($msg = preg_replace("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)) {
                                             if ($msg = preg_replace("/%%role%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($role), $msg)) {
                                                 if ($msg = preg_replace("/%%level%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($level), $msg)) {
                                                     if ($msg = preg_replace("/%%ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($ccaps), $msg)) {
                                                         if ($msg = preg_replace("/%%auto_eot_time%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($auto_eot_time), $msg)) {
                                                             if ($msg = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($fname), $msg)) {
                                                                 if ($msg = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($lname), $msg)) {
                                                                     if ($msg = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($name), $msg)) {
                                                                         if ($msg = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($email), $msg)) {
                                                                             if ($msg = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($login), $msg)) {
                                                                                 if ($msg = preg_replace("/%%user_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($pass), $msg)) {
                                                                                     if ($msg = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($ip), $msg)) {
                                                                                         if ($msg = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds($user_id), $msg)) {
                                                                                             foreach ($fields as $var => $val) {
                                                                                                 // Custom Fields.
                                                                                                 if (!($msg = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(maybe_serialize($val)), $msg))) {
                                                                                                     break;
                                                                                                 }
                                                                                             }
                                                                                             if ($sbj && ($msg = trim(preg_replace("/%%(.+?)%%/i", "", $msg)))) {
                                                                                                 // Still have a ``$sbj`` and a ``$msg``?
                                                                                                 foreach (c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_recipients"]) as $recipient) {
                                                                                                     wp_mail($recipient, apply_filters("ws_plugin__s2member_registration_notification_email_sbj", $sbj, get_defined_vars()), apply_filters("ws_plugin__s2member_registration_notification_email_msg", $msg, get_defined_vars()), "Content-Type: text/plain; charset=UTF-8");
                                                                                                 }
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                         if ($email_configs_were_on) {
                                             // Back on?
                                             c_ws_plugin__s2member_email_configs::email_config();
                                         }
                                         unset($sbj, $msg, $var, $val, $recipient, $email_configs_were_on);
                                         // Housekeeping.
                                     }
                                     if ($url = $GLOBALS["ws_plugin__s2member_registration_return_url"]) {
                                         if ($url = preg_replace("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)) {
                                             if ($url = preg_replace("/%%role%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($role)), $url)) {
                                                 if ($url = preg_replace("/%%level%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($level)), $url)) {
                                                     if ($url = preg_replace("/%%ccaps%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($ccaps)), $url)) {
                                                         if ($url = preg_replace("/%%auto_eot_time%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($auto_eot_time)), $url)) {
                                                             if ($url = preg_replace("/%%user_first_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($fname)), $url)) {
                                                                 if ($url = preg_replace("/%%user_last_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($lname)), $url)) {
                                                                     if ($url = preg_replace("/%%user_full_name%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($name)), $url)) {
                                                                         if ($url = preg_replace("/%%user_email%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($email)), $url)) {
                                                                             if ($url = preg_replace("/%%user_login%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($login)), $url)) {
                                                                                 if ($url = preg_replace("/%%user_pass%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($pass)), $url)) {
                                                                                     if ($url = preg_replace("/%%user_ip%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($ip)), $url)) {
                                                                                         if ($url = preg_replace("/%%user_id%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode($user_id)), $url)) {
                                                                                             foreach ($fields as $var => $val) {
                                                                                                 // Custom Fields.
                                                                                                 if (!($url = preg_replace("/%%" . preg_quote($var, "/") . "%%/i", c_ws_plugin__s2member_utils_strings::esc_ds(urlencode(maybe_serialize($val))), $url))) {
                                                                                                     break;
                                                                                                 }
                                                                                             }
                                                                                             if ($url = trim($url)) {
                                                                                                 // Preserve remaining Replacements; because the parent routine may perform replacements too.
                                                                                                 $GLOBALS["ws_plugin__s2member_registration_return_url"] = $url;
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                     unset($url, $var, $val);
                                     // Housekeeping.
                                     c_ws_plugin__s2member_list_servers::process_list_servers($role, $level, $login, $pass, $email, $fname, $lname, $ip, $opt_in, true, $user_id);
                                     /*
                                     Suppress errors here in case this routine is fired in unexpected locations; or with odd output buffering techniques.
                                     	@todo It may also be impossible to delete cookies when fired inside: `/wp-activate.php`.
                                     */
                                     if (!headers_sent()) {
                                         @setcookie("s2member_subscr_gateway", "", time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie("s2member_subscr_gateway", "", time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                                         @setcookie("s2member_subscr_id", "", time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie("s2member_subscr_id", "", time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                                         @setcookie("s2member_custom", "", time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie("s2member_custom", "", time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                                         @setcookie("s2member_item_number", "", time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie("s2member_item_number", "", time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                                     }
                                     /* If debugging/logging is enabled; we need to append ``$reg_vars`` to the log file.
                                     			Logging now supports Multisite Networking as well. */
                                     $reg_vars = get_defined_vars();
                                     // All defined vars.
                                     // No need to include these in the logs. Unset before log entry.
                                     unset($reg_vars["wpdb"], $reg_vars["current_site"], $reg_vars["current_blog"]);
                                     $logt = c_ws_plugin__s2member_utilities::time_details();
                                     $logv = c_ws_plugin__s2member_utilities::ver_details();
                                     $logm = c_ws_plugin__s2member_utilities::mem_details();
                                     $log4 = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\nUser-Agent: " . $_SERVER["HTTP_USER_AGENT"];
                                     $log4 = is_multisite() && !is_main_site() ? ($_log4 = $current_blog->domain . $current_blog->path) . "\n" . $log4 : $log4;
                                     $log2 = is_multisite() && !is_main_site() ? "reg-handler-4-" . trim(preg_replace("/[^a-z0-9]/i", "-", $_log4), "-") . ".log" : "reg-handler.log";
                                     if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["gateway_debug_logs"]) {
                                         if (is_dir($logs_dir = $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["logs_dir"])) {
                                             if (is_writable($logs_dir) && c_ws_plugin__s2member_utils_logs::archive_oversize_log_files()) {
                                                 file_put_contents($logs_dir . "/" . $log2, "LOG ENTRY: " . $logt . "\n" . $logv . "\n" . $logm . "\n" . $log4 . "\n" . c_ws_plugin__s2member_utils_logs::conceal_private_info(var_export($reg_vars, true)) . "\n\n", FILE_APPEND);
                                             }
                                         }
                                     }
                                     unset($logt, $logv, $logm, $log4, $_log4, $log2, $logs_dir, $reg_vars);
                                     // Housekeeping.
                                     foreach (array_keys(get_defined_vars()) as $__v) {
                                         $__refs[$__v] =& ${$__v};
                                     }
                                     do_action("ws_plugin__s2member_during_configure_user_registration", get_defined_vars());
                                     unset($__refs, $__v);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action("ws_plugin__s2member_after_configure_user_registration", get_defined_vars());
     unset($__refs, $__v);
     return;
 }
/**
 * Executes changes made in WordPress 4.5.0.
 *
 * @ignore
 * @since 4.5.0
 *
 * @global int  $wp_current_db_version Current database version.
 * @global wpdb $wpdb                  WordPress database abstraction object.
 */
function upgrade_450()
{
    global $wp_current_db_version, $wpdb;
    if ($wp_current_db_version < 36180) {
        wp_clear_scheduled_hook('wp_maybe_auto_update');
    }
    // Remove unused email confirmation options, moved to usermeta.
    if ($wp_current_db_version < 36679 && is_multisite()) {
        $wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name REGEXP '^[0-9]+_new_email\$'");
    }
    // Remove unused user setting for wpLink.
    delete_user_setting('wplink');
}
 /**
  * Configures all new Users.
  *
  * The Hook `user_register` is also fired by calling:
  * ``c_ws_plugin__s2member_registrations::ms_create_existing_user()`` and/or ``wpmu_create_user()``.
  *
  * This function also receives hand-offs from s2Member's handlers for these two Hooks:
  * `wpmu_activate_user` and `wpmu_activate_blog`.
  *
  * @package s2Member\Registrations
  * @since 3.5
  *
  * @attaches-to ``add_action('user_register');``
  *
  * @param int|string $user_id A numeric WordPress User ID.
  * @param string     $password Optional in most cases. A User's plain text Password. If unspecified, attempts are made to collect the plain text Password from other sources.
  * @param array      $meta Optional in most cases. Defaults to false. An array of meta data for a User/Member.
  *
  * @TODO Impossible to delete cookies when fired inside: `/wp-activate.php`?
  */
 public static function configure_user_registration($user_id = '', $password = '', $meta = array())
 {
     global $wpdb;
     // Global database object reference.
     global $pagenow;
     // We need this to detect the current administration page.
     global $current_site, $current_blog;
     // Adds support for Multisite Networking.
     static $email_config, $processed;
     // Static vars prevent duplicate processing.
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__s2member_before_configure_user_registration', get_defined_vars());
     unset($__refs, $__v);
     // Housekeeping.
     // With Multisite Networking, we need this to run on `user_register` ahead of `wpmu_activate_[user|blog]`.
     if (!isset($email_config) && ($email_config = TRUE)) {
         // Anytime this routine is fired; we configure email.
         c_ws_plugin__s2member_email_configs::email_config();
     }
     // Configures `From:` email header.
     $_p = isset($_POST) ? $_POST : NULL;
     // Grab global ``$_POST`` array here, if it's possible to do so.
     $rvs = isset($GLOBALS['ws_plugin__s2member_registration_vars']) ? $GLOBALS['ws_plugin__s2member_registration_vars'] : NULL;
     if (!$processed) {
         if (is_array($_p) || is_array($meta) || is_array($rvs)) {
             if (!(is_multisite() && is_blog_admin() && $pagenow === 'user-new.php' && isset($_p['noconfirmation']) && is_super_admin() && !is_array($meta))) {
                 if (!(preg_match('/\\/wp-activate\\.php/', $_SERVER['REQUEST_URI']) && !is_array($meta))) {
                     if (!(c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_activation_page() && !is_array($meta))) {
                         if (!(c_ws_plugin__s2member_utils_conds::pro_is_installed() && c_ws_plugin__s2member_pro_remote_ops::is_remote_op('create_user') && !is_array($rvs))) {
                             if ($user_id && is_object($user = new WP_User($user_id)) && !empty($user->ID) && ($user_id = $user->ID) && ($processed = TRUE)) {
                                 settype($_p, 'array') . settype($meta, 'array') . settype($rvs, 'array');
                                 // Force arrays here.
                                 $_p = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_p));
                                 $meta = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($meta));
                                 $rvs = c_ws_plugin__s2member_utils_strings::trim_deep($rvs);
                                 foreach ($_p as $_key => $_value) {
                                     // Scan ``$_p`` vars; adding `custom_reg_field` keys.
                                     if (preg_match('/^ws_plugin__s2member_user_new_/', $_key)) {
                                         // Look for keys.
                                         if ($_key = str_replace('_user_new_', '_custom_reg_field_', $_key)) {
                                             $_p[$_key] = $_value;
                                         }
                                     }
                                 }
                                 // Add each of these key conversions.
                                 unset($_key, $_value);
                                 if (!is_admin() && (isset($_p['ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_subscr_id']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_subscr_baid']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_subscr_cid']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_custom']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_ccaps']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time']) || isset($_p['ws_plugin__s2member_custom_reg_field_s2member_notes']))) {
                                     exit(_x('s2Member security violation. You attempted to POST administrative variables that will NOT be trusted in a NON-administrative zone!', 's2member-front', 's2member'));
                                 }
                                 $_pmr = array_merge($_p, $meta, $rvs);
                                 // Merge all of these arrays together now, in this specific order.
                                 unset($_p, $meta, $rvs);
                                 // These variables can all be unset now; we have them all in the ``$_pmr`` array.
                                 $custom_reg_display_name = $GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_display_name'];
                                 // Can be configured by the site owner.
                                 if (!is_admin() && (!c_ws_plugin__s2member_utils_conds::pro_is_installed() || !c_ws_plugin__s2member_pro_remote_ops::is_remote_op('create_user')) && ($reg_cookies = c_ws_plugin__s2member_register_access::reg_cookies_ok()) && extract($reg_cookies)) {
                                     /* This routine could be processed through `/wp-login.php?action=register`, `/wp-activate.php`, or `/activate` via BuddyPress`.
                                     			This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`.
                                     			If processed through `/wp-activate.php`, it could've originated inside the admin—via `/user-new.php`. */
                                     /**
                                      * @var $subscr_gateway string Reference for IDEs.
                                      * @var $subscr_id string Reference for IDEs.
                                      * @var $custom string Reference for IDEs.
                                      * @var $item_number string Reference for IDEs.
                                      */
                                     $processed = 'yes';
                                     // Mark this as yes.
                                     $current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
                                     @(list($level, $ccaps, $eotper) = preg_split('/\\:/', $item_number, 3));
                                     $role = 's2member_level' . $level;
                                     // Membership Level.
                                     $email = $user->user_email;
                                     $login = $user->user_login;
                                     $ip = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_registration_ip'];
                                     $ip = !$ip ? $_SERVER['REMOTE_ADDR'] : $ip;
                                     // Else use environment variable.
                                     $subscr_baid = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_baid'];
                                     $subscr_cid = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_cid'];
                                     $cv = preg_split('/\\|/', $custom);
                                     if (!($auto_eot_time = '') && $eotper) {
                                         // If a specific EOT Period is included.
                                         $auto_eot_time = c_ws_plugin__s2member_utils_time::auto_eot_time('', '', '', $eotper);
                                     }
                                     $notes = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_notes'];
                                     $opt_in = !$GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_opt_in'] ? TRUE : FALSE;
                                     $opt_in = !$opt_in && !empty($_pmr['ws_plugin__s2member_custom_reg_field_opt_in']) ? TRUE : $opt_in;
                                     if (!($fname = $user->first_name)) {
                                         if (!empty($_pmr['ws_plugin__s2member_custom_reg_field_first_name'])) {
                                             $fname = (string) $_pmr['ws_plugin__s2member_custom_reg_field_first_name'];
                                         }
                                     }
                                     if (!$fname) {
                                         // Also try BuddyPress.
                                         if (!empty($_pmr['field_1'])) {
                                             // BuddyPress?
                                             $fname = trim(preg_replace('/ (.*)$/', '', (string) $_pmr['field_1']));
                                         }
                                     }
                                     if (!($lname = $user->last_name)) {
                                         if (!empty($_pmr['ws_plugin__s2member_custom_reg_field_last_name'])) {
                                             $lname = (string) $_pmr['ws_plugin__s2member_custom_reg_field_last_name'];
                                         }
                                     }
                                     if (!$lname) {
                                         // Also try BuddyPress.
                                         if (!empty($_pmr['field_1']) && preg_match('/^(.+?) (.+)$/', (string) $_pmr['field_1'])) {
                                             $lname = trim(preg_replace('/^(.+?) (.+)$/', '$2', (string) $_pmr['field_1']));
                                         }
                                     }
                                     if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_names'] && !$fname && $login) {
                                         $fname = trim($login);
                                         $lname = '';
                                         // Username and empty Last Name.
                                     }
                                     $name = trim($fname . ' ' . $lname);
                                     // Both names.
                                     if (!($pass = $password)) {
                                         // Try s2Member's generator.
                                         if (!empty($GLOBALS['ws_plugin__s2member_plain_text_pass'])) {
                                             $pass = (string) $GLOBALS['ws_plugin__s2member_plain_text_pass'];
                                         }
                                     }
                                     if (!$pass) {
                                         // Also try BuddyPress Password.
                                         if (!empty($_pmr['signup_password'])) {
                                             // BuddyPress?
                                             $pass = (string) $_pmr['signup_password'];
                                         }
                                     }
                                     if ($pass) {
                                         !headers_sent() ? delete_user_setting('default_password_nag', $user_id) : NULL;
                                         update_user_option($user_id, 'default_password_nag', FALSE, TRUE);
                                     }
                                     update_user_option($user_id, 's2member_registration_ip', $ip);
                                     update_user_option($user_id, 's2member_auto_eot_time', $auto_eot_time);
                                     update_user_option($user_id, 's2member_subscr_gateway', $subscr_gateway);
                                     update_user_option($user_id, 's2member_subscr_id', $subscr_id);
                                     update_user_option($user_id, 's2member_subscr_baid', $subscr_baid);
                                     update_user_option($user_id, 's2member_subscr_cid', $subscr_cid);
                                     update_user_option($user_id, 's2member_custom', $custom);
                                     update_user_option($user_id, 's2member_notes', $notes);
                                     if (!$user->first_name && $fname) {
                                         update_user_meta($user_id, 'first_name', $fname);
                                     }
                                     if (!$user->last_name && $lname) {
                                         update_user_meta($user_id, 'last_name', $lname);
                                     }
                                     if (!$user->display_name || $user->display_name === $user->user_login) {
                                         if ($custom_reg_display_name === 'full' && $name) {
                                             wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $name)));
                                         } else {
                                             if ($custom_reg_display_name === 'first' && $fname) {
                                                 wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $fname)));
                                             } else {
                                                 if ($custom_reg_display_name === 'last' && $lname) {
                                                     wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $lname)));
                                                 } else {
                                                     if ($custom_reg_display_name === 'login' && $login) {
                                                         wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $login)));
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                     if (is_multisite()) {
                                         if (!is_main_site() && strtotime($user->user_registered) >= strtotime('-10 seconds')) {
                                             remove_user_from_blog($user_id, $current_site->blog_id);
                                         }
                                         // No Main Site Role.
                                         if (!get_user_meta($user_id, 's2member_originating_blog', TRUE)) {
                                             // Recorded yet?
                                             update_user_meta($user_id, 's2member_originating_blog', $current_blog->blog_id);
                                         }
                                     }
                                     if ($current_role !== $role) {
                                         // Only if NOT the current Role.
                                         $user->set_role($role);
                                     }
                                     // s2Member.
                                     if ($ccaps && preg_match('/^-all/', str_replace('+', '', $ccaps))) {
                                         foreach ($user->allcaps as $cap => $cap_enabled) {
                                             if (preg_match('/^access_s2member_ccap_/', $cap)) {
                                                 $user->remove_cap($ccap = $cap);
                                             }
                                         }
                                     }
                                     if ($ccaps && preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $ccaps))) {
                                         foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $ccaps))) as $ccap) {
                                             if (strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap))))) {
                                                 $user->add_cap('access_s2member_ccap_' . $ccap);
                                             }
                                         }
                                     }
                                     if (!($fields = array()) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields']) {
                                         foreach (json_decode($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'], TRUE) as $field) {
                                             $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id']));
                                             $field_id_class = preg_replace('/_/', '-', $field_var);
                                             if (isset($_pmr['ws_plugin__s2member_custom_reg_field_' . $field_var])) {
                                                 $fields[$field_var] = $_pmr['ws_plugin__s2member_custom_reg_field_' . $field_var];
                                             }
                                         }
                                     }
                                     unset($field, $field_var, $field_id_class);
                                     // Housekeeping.
                                     if (!empty($fields)) {
                                         // Only if NOT empty.
                                         update_user_option($user_id, 's2member_custom_fields', $fields);
                                     }
                                     if ($level > 0) {
                                         $pr_times = get_user_option('s2member_paid_registration_times', $user_id);
                                         $pr_times['level'] = empty($pr_times['level']) ? time() : $pr_times['level'];
                                         $pr_times['level' . $level] = empty($pr_times['level' . $level]) ? time() : $pr_times['level' . $level];
                                         update_user_option($user_id, 's2member_paid_registration_times', $pr_times);
                                         // Update now.
                                     }
                                     if (!is_multisite() && c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_register_page()) {
                                         update_user_option($user_id, 's2member_bp_activation_role', $role);
                                         update_user_option($user_id, 's2member_bp_activation_ccaps', c_ws_plugin__s2member_user_access::user_access_ccaps($user));
                                     }
                                     if (($transient = 's2m_' . md5('s2member_transient_ipn_signup_vars_' . $subscr_id)) && is_array($ipn_signup_vars = get_transient($transient))) {
                                         update_user_option($user_id, 's2member_ipn_signup_vars', $ipn_signup_vars);
                                         // For future reference.
                                         delete_transient($transient);
                                         // This can be deleted now.
                                     }
                                     if (($transient = 's2m_' . md5('s2member_transient_ipn_subscr_payment_' . $subscr_id)) && is_array($subscr_payment = get_transient($transient)) && !empty($subscr_payment['subscr_gateway'])) {
                                         $proxy = array('s2member_paypal_proxy' => stripslashes((string) $subscr_payment['subscr_gateway']), 's2member_paypal_proxy_verification' => c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
                                         c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), array_merge(stripslashes_deep($subscr_payment), $proxy), array('timeout' => 20));
                                         delete_transient($transient);
                                         // This can be deleted now.
                                     }
                                     if (($transient = 's2m_' . md5('s2member_transient_ipn_subscr_eot_' . $subscr_id)) && is_array($subscr_eot = get_transient($transient)) && !empty($subscr_eot['subscr_gateway'])) {
                                         $proxy = array('s2member_paypal_proxy' => stripslashes((string) $subscr_eot['subscr_gateway']), 's2member_paypal_proxy_verification' => c_ws_plugin__s2member_paypal_utilities::paypal_proxy_key_gen());
                                         c_ws_plugin__s2member_utils_urls::remote(home_url('/?s2member_paypal_notify=1'), array_merge(stripslashes_deep($subscr_eot), $proxy), array('timeout' => 20));
                                         delete_transient($transient);
                                         // This can be deleted now.
                                     }
                                     if (!headers_sent()) {
                                         // Only if headers are NOT yet sent. Here we establish both Signup and Payment Tracking Cookies.
                                         @setcookie('s2member_tracking', $s2member_tracking = c_ws_plugin__s2member_utils_encryption::encrypt($subscr_id), time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie('s2member_tracking', $s2member_tracking, time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN) . ($_COOKIE['s2member_tracking'] = $s2member_tracking);
                                     }
                                     foreach (array_keys(get_defined_vars()) as $__v) {
                                         $__refs[$__v] =& ${$__v};
                                     }
                                     do_action('ws_plugin__s2member_during_configure_user_registration_front_side_paid', get_defined_vars());
                                     do_action('ws_plugin__s2member_during_configure_user_registration_front_side', get_defined_vars());
                                     unset($__refs, $__v);
                                 } else {
                                     if (!is_admin() && (!c_ws_plugin__s2member_utils_conds::pro_is_installed() || !c_ws_plugin__s2member_pro_remote_ops::is_remote_op('create_user'))) {
                                         /* This routine could be processed through `/wp-login.php?action=register`, `/wp-activate.php`, or `/activate` via BuddyPress`.
                                         			This may also be processed through a standard BuddyPress installation, or another plugin calling `user_register`.
                                         			If processed through `/wp-activate.php`, it could've originated inside the admin, via `/user-new.php`. */
                                         $processed = 'yes';
                                         // Mark this as yes.
                                         $current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
                                         $role = '';
                                         // Initialize ``$role`` to an empty string here, before processing.
                                         $role = !$role && ($level = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level']) > 0 ? 's2member_level' . $level : $role;
                                         $role = !$role && ($level = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level']) === '0' ? 'subscriber' : $role;
                                         $role = !$role && $current_role ? $current_role : $role;
                                         // Use existing Role?
                                         $role = !$role ? get_option('default_role') : $role;
                                         // Otherwise default.
                                         $level = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level'];
                                         $level = !$level && preg_match('/^(administrator|editor|author|contributor)$/i', $role) ? $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels'] : $level;
                                         $level = !$level && preg_match('/^s2member_level[1-9][0-9]*$/i', $role) ? preg_replace('/^s2member_level/', '', $role) : $level;
                                         $level = !$level && preg_match('/^subscriber$/i', $role) ? '0' : $level;
                                         $level = !$level ? '0' : $level;
                                         $ccaps = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_ccaps'];
                                         $email = $user->user_email;
                                         $login = $user->user_login;
                                         $ip = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_registration_ip'];
                                         $ip = !$ip ? $_SERVER['REMOTE_ADDR'] : $ip;
                                         // Else use environment variable.
                                         $custom = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_custom'];
                                         $subscr_id = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_id'];
                                         $subscr_baid = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_baid'];
                                         $subscr_cid = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_cid'];
                                         $subscr_gateway = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway'];
                                         $cv = preg_split('/\\|/', (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_custom']);
                                         $auto_eot_time = ($eot = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time']) ? strtotime($eot) : '';
                                         $notes = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_notes'];
                                         $opt_in = !$GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_opt_in'] ? TRUE : FALSE;
                                         $opt_in = !$opt_in && !empty($_pmr['ws_plugin__s2member_custom_reg_field_opt_in']) ? TRUE : $opt_in;
                                         if (!($fname = $user->first_name)) {
                                             if (!empty($_pmr['ws_plugin__s2member_custom_reg_field_first_name'])) {
                                                 $fname = (string) $_pmr['ws_plugin__s2member_custom_reg_field_first_name'];
                                             }
                                         }
                                         if (!$fname) {
                                             // Also try BuddyPress.
                                             if (!empty($_pmr['field_1'])) {
                                                 // BuddyPress?
                                                 $fname = trim(preg_replace('/ (.*)$/', '', (string) $_pmr['field_1']));
                                             }
                                         }
                                         if (!($lname = $user->last_name)) {
                                             if (!empty($_pmr['ws_plugin__s2member_custom_reg_field_last_name'])) {
                                                 $lname = (string) $_pmr['ws_plugin__s2member_custom_reg_field_last_name'];
                                             }
                                         }
                                         if (!$lname) {
                                             // Also try BuddyPress.
                                             if (!empty($_pmr['field_1']) && preg_match('/^(.+?) (.+)$/', (string) $_pmr['field_1'])) {
                                                 $lname = trim(preg_replace('/^(.+?) (.+)$/', '$2', (string) $_pmr['field_1']));
                                             }
                                         }
                                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_names'] && !$fname && $login) {
                                             $fname = trim($login);
                                             $lname = '';
                                             // Username and empty Last Name.
                                         }
                                         $name = trim($fname . ' ' . $lname);
                                         // Both names.
                                         if (!($pass = $password)) {
                                             // Try s2Member's generator.
                                             if (!empty($GLOBALS['ws_plugin__s2member_plain_text_pass'])) {
                                                 $pass = (string) $GLOBALS['ws_plugin__s2member_plain_text_pass'];
                                             }
                                         }
                                         if (!$pass) {
                                             // Also try BuddyPress Password.
                                             if (!empty($_pmr['signup_password'])) {
                                                 // BuddyPress?
                                                 $pass = (string) $_pmr['signup_password'];
                                             }
                                         }
                                         if ($pass) {
                                             !headers_sent() ? delete_user_setting('default_password_nag', $user_id) : NULL;
                                             update_user_option($user_id, 'default_password_nag', FALSE, TRUE);
                                         }
                                         update_user_option($user_id, 's2member_registration_ip', $ip);
                                         update_user_option($user_id, 's2member_auto_eot_time', $auto_eot_time);
                                         update_user_option($user_id, 's2member_subscr_gateway', $subscr_gateway);
                                         update_user_option($user_id, 's2member_subscr_id', $subscr_id);
                                         update_user_option($user_id, 's2member_subscr_baid', $subscr_baid);
                                         update_user_option($user_id, 's2member_subscr_cid', $subscr_cid);
                                         update_user_option($user_id, 's2member_custom', $custom);
                                         update_user_option($user_id, 's2member_notes', $notes);
                                         if (!$user->first_name && $fname) {
                                             update_user_meta($user_id, 'first_name', $fname);
                                         }
                                         if (!$user->last_name && $lname) {
                                             update_user_meta($user_id, 'last_name', $lname);
                                         }
                                         if (!$user->display_name || $user->display_name === $user->user_login) {
                                             if ($custom_reg_display_name === 'full' && $name) {
                                                 wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $name)));
                                             } else {
                                                 if ($custom_reg_display_name === 'first' && $fname) {
                                                     wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $fname)));
                                                 } else {
                                                     if ($custom_reg_display_name === 'last' && $lname) {
                                                         wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $lname)));
                                                     } else {
                                                         if ($custom_reg_display_name === 'login' && $login) {
                                                             wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $login)));
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                         if (is_multisite()) {
                                             if (!is_main_site() && strtotime($user->user_registered) >= strtotime('-10 seconds')) {
                                                 remove_user_from_blog($user_id, $current_site->blog_id);
                                             }
                                             // No Main Site Role.
                                             if (!get_user_meta($user_id, 's2member_originating_blog', TRUE)) {
                                                 // Recorded yet?
                                                 update_user_meta($user_id, 's2member_originating_blog', $current_blog->blog_id);
                                             }
                                         }
                                         if ($current_role !== $role) {
                                             // Only if NOT the current Role.
                                             $user->set_role($role);
                                         }
                                         // s2Member.
                                         if ($ccaps && preg_match('/^-all/', str_replace('+', '', $ccaps))) {
                                             foreach ($user->allcaps as $cap => $cap_enabled) {
                                                 if (preg_match('/^access_s2member_ccap_/', $cap)) {
                                                     $user->remove_cap($ccap = $cap);
                                                 }
                                             }
                                         }
                                         if ($ccaps && preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $ccaps))) {
                                             foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $ccaps))) as $ccap) {
                                                 if (strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap))))) {
                                                     $user->add_cap('access_s2member_ccap_' . $ccap);
                                                 }
                                             }
                                         }
                                         if (!($fields = array()) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields']) {
                                             foreach (json_decode($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'], TRUE) as $field) {
                                                 $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id']));
                                                 $field_id_class = preg_replace('/_/', '-', $field_var);
                                                 if (isset($_pmr['ws_plugin__s2member_custom_reg_field_' . $field_var])) {
                                                     $fields[$field_var] = $_pmr['ws_plugin__s2member_custom_reg_field_' . $field_var];
                                                 }
                                             }
                                         }
                                         unset($field, $field_var, $field_id_class);
                                         // Housekeeping.
                                         if (!empty($fields)) {
                                             // Only if NOT empty.
                                             update_user_option($user_id, 's2member_custom_fields', $fields);
                                         }
                                         if ($level > 0) {
                                             $pr_times = get_user_option('s2member_paid_registration_times', $user_id);
                                             $pr_times['level'] = empty($pr_times['level']) ? time() : $pr_times['level'];
                                             $pr_times['level' . $level] = empty($pr_times['level' . $level]) ? time() : $pr_times['level' . $level];
                                             update_user_option($user_id, 's2member_paid_registration_times', $pr_times);
                                             // Update now.
                                         }
                                         if (!is_multisite() && c_ws_plugin__s2member_utils_conds::bp_is_installed() && bp_is_register_page()) {
                                             update_user_option($user_id, 's2member_bp_activation_role', $role);
                                             update_user_option($user_id, 's2member_bp_activation_ccaps', c_ws_plugin__s2member_user_access::user_access_ccaps($user));
                                         }
                                         foreach (array_keys(get_defined_vars()) as $__v) {
                                             $__refs[$__v] =& ${$__v};
                                         }
                                         do_action('ws_plugin__s2member_during_configure_user_registration_front_side_free', get_defined_vars());
                                         do_action('ws_plugin__s2member_during_configure_user_registration_front_side', get_defined_vars());
                                         unset($__refs, $__v);
                                     } else {
                                         if (is_blog_admin() && $pagenow === 'user-new.php' || c_ws_plugin__s2member_utils_conds::pro_is_installed() && c_ws_plugin__s2member_pro_remote_ops::is_remote_op('create_user')) {
                                             // Can only be processed through `/user-new.php` in the Admin panel, or through Remote Op: `create_user`.
                                             $processed = 'yes';
                                             // Mark this as yes, to indicate that a routine was processed.
                                             $current_role = c_ws_plugin__s2member_user_access::user_access_role($user);
                                             $role = '';
                                             // Initialize $role to an empty string here, before processing.
                                             $role = !$role && ($level = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level']) > 0 ? 's2member_level' . $level : $role;
                                             $role = !$role && ($level = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level']) === '0' ? 'subscriber' : $role;
                                             $role = !$role && $current_role ? $current_role : $role;
                                             // Use existing Role?
                                             $role = !$role ? get_option('default_role') : $role;
                                             // Otherwise default.
                                             $level = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_level'];
                                             $level = !$level && preg_match('/^(administrator|editor|author|contributor)$/i', $role) ? $GLOBALS['WS_PLUGIN__']['s2member']['c']['levels'] : $level;
                                             $level = !$level && preg_match('/^s2member_level[1-9][0-9]*$/i', $role) ? preg_replace('/^s2member_level/', '', $role) : $level;
                                             $level = !$level && preg_match('/^subscriber$/i', $role) ? '0' : $level;
                                             $level = !$level ? '0' : $level;
                                             $ccaps = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_ccaps'];
                                             $email = $user->user_email;
                                             $login = $user->user_login;
                                             $ip = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_registration_ip'];
                                             $custom = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_custom'];
                                             $subscr_id = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_id'];
                                             $subscr_baid = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_baid'];
                                             $subscr_cid = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_cid'];
                                             $subscr_gateway = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_subscr_gateway'];
                                             $cv = preg_split('/\\|/', (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_custom']);
                                             $auto_eot_time = ($eot = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time']) ? strtotime($eot) : '';
                                             $notes = (string) @$_pmr['ws_plugin__s2member_custom_reg_field_s2member_notes'];
                                             $opt_in = !empty($_pmr['ws_plugin__s2member_custom_reg_field_opt_in']) ? TRUE : FALSE;
                                             if (!($fname = $user->first_name)) {
                                                 // `Users → Add New`.
                                                 if (!empty($_pmr['ws_plugin__s2member_custom_reg_field_first_name'])) {
                                                     $fname = (string) $_pmr['ws_plugin__s2member_custom_reg_field_first_name'];
                                                 }
                                             }
                                             if (!($lname = $user->last_name)) {
                                                 // `Users → Add New`.
                                                 if (!empty($_pmr['ws_plugin__s2member_custom_reg_field_last_name'])) {
                                                     $lname = (string) $_pmr['ws_plugin__s2member_custom_reg_field_last_name'];
                                                 }
                                             }
                                             if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_names'] && !$fname && $login) {
                                                 $fname = trim($login);
                                                 $lname = '';
                                                 // Username and empty Last Name.
                                             }
                                             $name = trim($fname . ' ' . $lname);
                                             // Both names.
                                             if (!($pass = $password)) {
                                                 // Try s2Member's generator.
                                                 if (!empty($GLOBALS['ws_plugin__s2member_plain_text_pass'])) {
                                                     $pass = (string) $GLOBALS['ws_plugin__s2member_plain_text_pass'];
                                                 }
                                             }
                                             if (!$pass) {
                                                 // Also try the `Users → Add New` form.
                                                 if (!empty($_pmr['pass1'])) {
                                                     // Field in `/user-new.php`.
                                                     $pass = (string) $_pmr['pass1'];
                                                 }
                                             }
                                             if ($pass) {
                                                 !headers_sent() ? delete_user_setting('default_password_nag', $user_id) : NULL;
                                                 update_user_option($user_id, 'default_password_nag', FALSE, TRUE);
                                             }
                                             update_user_option($user_id, 's2member_registration_ip', $ip);
                                             update_user_option($user_id, 's2member_auto_eot_time', $auto_eot_time);
                                             update_user_option($user_id, 's2member_subscr_gateway', $subscr_gateway);
                                             update_user_option($user_id, 's2member_subscr_id', $subscr_id);
                                             update_user_option($user_id, 's2member_subscr_baid', $subscr_baid);
                                             update_user_option($user_id, 's2member_subscr_cid', $subscr_cid);
                                             update_user_option($user_id, 's2member_custom', $custom);
                                             update_user_option($user_id, 's2member_notes', $notes);
                                             if (!$user->first_name && $fname) {
                                                 update_user_meta($user_id, 'first_name', $fname);
                                             }
                                             if (!$user->last_name && $lname) {
                                                 update_user_meta($user_id, 'last_name', $lname);
                                             }
                                             if (!$user->display_name || $user->display_name === $user->user_login) {
                                                 if ($custom_reg_display_name === 'full' && $name) {
                                                     wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $name)));
                                                 } else {
                                                     if ($custom_reg_display_name === 'first' && $fname) {
                                                         wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $fname)));
                                                     } else {
                                                         if ($custom_reg_display_name === 'last' && $lname) {
                                                             wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $lname)));
                                                         } else {
                                                             if ($custom_reg_display_name === 'login' && $login) {
                                                                 wp_update_user(wp_slash(array('ID' => $user_id, 'display_name' => $login)));
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                             if (is_multisite()) {
                                                 if (!is_main_site() && strtotime($user->user_registered) >= strtotime('-10 seconds')) {
                                                     remove_user_from_blog($user_id, $current_site->blog_id);
                                                 }
                                                 // No Main Site Role.
                                                 if (!get_user_meta($user_id, 's2member_originating_blog', TRUE)) {
                                                     // Recorded yet?
                                                     update_user_meta($user_id, 's2member_originating_blog', $current_blog->blog_id);
                                                 }
                                             }
                                             if ($current_role !== $role) {
                                                 // Only if NOT the current Role.
                                                 $user->set_role($role);
                                             }
                                             // s2Member.
                                             if ($ccaps && preg_match('/^-all/', str_replace('+', '', $ccaps))) {
                                                 foreach ($user->allcaps as $cap => $cap_enabled) {
                                                     if (preg_match('/^access_s2member_ccap_/', $cap)) {
                                                         $user->remove_cap($ccap = $cap);
                                                     }
                                                 }
                                             }
                                             if ($ccaps && preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $ccaps))) {
                                                 foreach (preg_split('/[' . "\r\n\t" . '\\s;,]+/', preg_replace('/^-all[' . "\r\n\t" . '\\s;,]*/', '', str_replace('+', '', $ccaps))) as $ccap) {
                                                     if (strlen($ccap = trim(strtolower(preg_replace('/[^a-z_0-9]/i', '', $ccap))))) {
                                                         $user->add_cap('access_s2member_ccap_' . $ccap);
                                                     }
                                                 }
                                             }
                                             if (!($fields = array()) && $GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields']) {
                                                 foreach (json_decode($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_fields'], TRUE) as $field) {
                                                     $field_var = preg_replace('/[^a-z0-9]/i', '_', strtolower($field['id']));
                                                     $field_id_class = preg_replace('/_/', '-', $field_var);
                                                     if (isset($_pmr['ws_plugin__s2member_custom_reg_field_' . $field_var])) {
                                                         $fields[$field_var] = $_pmr['ws_plugin__s2member_custom_reg_field_' . $field_var];
                                                     }
                                                 }
                                             }
                                             unset($field, $field_var, $field_id_class);
                                             // Housekeeping.
                                             if (!empty($fields)) {
                                                 // Only if NOT empty.
                                                 update_user_option($user_id, 's2member_custom_fields', $fields);
                                             }
                                             if ($level > 0) {
                                                 $pr_times = get_user_option('s2member_paid_registration_times', $user_id);
                                                 $pr_times['level'] = empty($pr_times['level']) ? time() : $pr_times['level'];
                                                 $pr_times['level' . $level] = empty($pr_times['level' . $level]) ? time() : $pr_times['level' . $level];
                                                 update_user_option($user_id, 's2member_paid_registration_times', $pr_times);
                                                 // Update now.
                                             }
                                             foreach (array_keys(get_defined_vars()) as $__v) {
                                                 $__refs[$__v] =& ${$__v};
                                             }
                                             do_action('ws_plugin__s2member_during_configure_user_registration_admin_side', get_defined_vars());
                                             unset($__refs, $__v);
                                         }
                                     }
                                 }
                                 if ($processed === 'yes') {
                                     /**
                                      * If processed, all of these will have been defined by now.
                                      *
                                      * @var $role string Reference for IDEs.
                                      * @var $level string Reference for IDEs.
                                      * @var $ccaps string Reference for IDEs.
                                      * @var $auto_eot_time string|integer Reference for IDEs.
                                      * @var $fname string Reference for IDEs.
                                      * @var $lname string Reference for IDEs.
                                      * @var $name string Reference for IDEs.
                                      * @var $email string Reference for IDEs.
                                      * @var $login string Reference for IDEs.
                                      * @var $pass string Reference for IDEs.
                                      * @var $ip string Reference for IDEs.
                                      * @var $opt_in boolean Reference for IDEs.
                                      * @var $fields array Reference for IDEs.
                                      */
                                     if ($urls = $GLOBALS['WS_PLUGIN__']['s2member']['o']['registration_notification_urls']) {
                                         foreach (preg_split('/[' . "\r\n\t" . ']+/', $urls) as $url) {
                                             // Notify each of the URLs.
                                             if ($url = preg_replace('/%%cv([0-9]+)%%/ei', 'urlencode(trim(@$cv[$1]))', $url)) {
                                                 if ($url = preg_replace('/%%role%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($role)), $url)) {
                                                     if ($url = preg_replace('/%%level%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($level)), $url)) {
                                                         if ($url = preg_replace('/%%ccaps%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($ccaps)), $url)) {
                                                             if ($url = preg_replace('/%%auto_eot_time%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($auto_eot_time)), $url)) {
                                                                 if ($url = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($fname)), $url)) {
                                                                     if ($url = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($lname)), $url)) {
                                                                         if ($url = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($name)), $url)) {
                                                                             if ($url = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($email)), $url)) {
                                                                                 if ($url = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($login)), $url)) {
                                                                                     if ($url = preg_replace('/%%user_pass%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($pass)), $url)) {
                                                                                         if ($url = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($ip)), $url)) {
                                                                                             if ($url = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_id)), $url)) {
                                                                                                 foreach ($fields as $var => $val) {
                                                                                                     // Custom Fields.
                                                                                                     if (!($url = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(maybe_serialize($val))), $url))) {
                                                                                                         break;
                                                                                                     }
                                                                                                 }
                                                                                                 if ($url = trim(preg_replace('/%%(.+?)%%/i', '', $url))) {
                                                                                                     c_ws_plugin__s2member_utils_urls::remote($url);
                                                                                                 }
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                     unset($urls, $url, $var, $val);
                                     // Housekeeping.
                                     if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['registration_notification_recipients']) {
                                         $email_configs_were_on = c_ws_plugin__s2member_email_configs::email_config_status();
                                         c_ws_plugin__s2member_email_configs::email_config_release();
                                         $msg = $sbj = '(s2Member / API Notification Email) - Registration';
                                         $msg .= "\n\n";
                                         // Spacing in the message body.
                                         $msg .= 'role: %%role%%' . "\n";
                                         $msg .= 'level: %%level%%' . "\n";
                                         $msg .= 'ccaps: %%ccaps%%' . "\n";
                                         $msg .= 'auto_eot_time: %%auto_eot_time%%' . "\n";
                                         $msg .= 'user_first_name: %%user_first_name%%' . "\n";
                                         $msg .= 'user_last_name: %%user_last_name%%' . "\n";
                                         $msg .= 'user_full_name: %%user_full_name%%' . "\n";
                                         $msg .= 'user_email: %%user_email%%' . "\n";
                                         $msg .= 'user_login: %%user_login%%' . "\n";
                                         $msg .= 'user_pass: %%user_pass%%' . "\n";
                                         $msg .= 'user_ip: %%user_ip%%' . "\n";
                                         $msg .= 'user_id: %%user_id%%' . "\n";
                                         foreach ($fields as $var => $val) {
                                             $msg .= $var . ': %%' . $var . '%%' . "\n";
                                         }
                                         $msg .= 'cv0: %%cv0%%' . "\n";
                                         $msg .= 'cv1: %%cv1%%' . "\n";
                                         $msg .= 'cv2: %%cv2%%' . "\n";
                                         $msg .= 'cv3: %%cv3%%' . "\n";
                                         $msg .= 'cv4: %%cv4%%' . "\n";
                                         $msg .= 'cv5: %%cv5%%' . "\n";
                                         $msg .= 'cv6: %%cv6%%' . "\n";
                                         $msg .= 'cv7: %%cv7%%' . "\n";
                                         $msg .= 'cv8: %%cv8%%' . "\n";
                                         $msg .= 'cv9: %%cv9%%';
                                         if ($msg = preg_replace('/%%cv([0-9]+)%%/ei', 'trim(@$cv[$1])', $msg)) {
                                             if ($msg = preg_replace('/%%role%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($role), $msg)) {
                                                 if ($msg = preg_replace('/%%level%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($level), $msg)) {
                                                     if ($msg = preg_replace('/%%ccaps%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($ccaps), $msg)) {
                                                         if ($msg = preg_replace('/%%auto_eot_time%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($auto_eot_time), $msg)) {
                                                             if ($msg = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($fname), $msg)) {
                                                                 if ($msg = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($lname), $msg)) {
                                                                     if ($msg = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($name), $msg)) {
                                                                         if ($msg = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($email), $msg)) {
                                                                             if ($msg = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($login), $msg)) {
                                                                                 if ($msg = preg_replace('/%%user_pass%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($pass), $msg)) {
                                                                                     if ($msg = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($ip), $msg)) {
                                                                                         if ($msg = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs($user_id), $msg)) {
                                                                                             foreach ($fields as $var => $val) {
                                                                                                 // Custom Fields.
                                                                                                 if (!($msg = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(maybe_serialize($val)), $msg))) {
                                                                                                     break;
                                                                                                 }
                                                                                             }
                                                                                             if ($sbj && ($msg = trim(preg_replace('/%%(.+?)%%/i', '', $msg)))) {
                                                                                                 // Still have a ``$sbj`` and a ``$msg``?
                                                                                                 foreach (c_ws_plugin__s2member_utils_strings::parse_emails($GLOBALS['WS_PLUGIN__']['s2member']['o']['registration_notification_recipients']) as $recipient) {
                                                                                                     wp_mail($recipient, apply_filters('ws_plugin__s2member_registration_notification_email_sbj', $sbj, get_defined_vars()), apply_filters('ws_plugin__s2member_registration_notification_email_msg', $msg, get_defined_vars()), 'Content-Type: text/plain; charset=UTF-8');
                                                                                                 }
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                         if ($email_configs_were_on) {
                                             // Back on?
                                             c_ws_plugin__s2member_email_configs::email_config();
                                         }
                                         unset($sbj, $msg, $var, $val, $recipient, $email_configs_were_on);
                                         // Housekeeping.
                                     }
                                     if (!empty($GLOBALS['ws_plugin__s2member_registration_return_url']) && ($url = $GLOBALS['ws_plugin__s2member_registration_return_url'])) {
                                         if ($url = preg_replace('/%%cv([0-9]+)%%/ei', 'urlencode(trim(@$cv[$1]))', $url)) {
                                             if ($url = preg_replace('/%%role%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($role)), $url)) {
                                                 if ($url = preg_replace('/%%level%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($level)), $url)) {
                                                     if ($url = preg_replace('/%%ccaps%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($ccaps)), $url)) {
                                                         if ($url = preg_replace('/%%auto_eot_time%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($auto_eot_time)), $url)) {
                                                             if ($url = preg_replace('/%%user_first_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($fname)), $url)) {
                                                                 if ($url = preg_replace('/%%user_last_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($lname)), $url)) {
                                                                     if ($url = preg_replace('/%%user_full_name%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($name)), $url)) {
                                                                         if ($url = preg_replace('/%%user_email%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($email)), $url)) {
                                                                             if ($url = preg_replace('/%%user_login%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($login)), $url)) {
                                                                                 if ($url = preg_replace('/%%user_pass%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($pass)), $url)) {
                                                                                     if ($url = preg_replace('/%%user_ip%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($ip)), $url)) {
                                                                                         if ($url = preg_replace('/%%user_id%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode($user_id)), $url)) {
                                                                                             foreach ($fields as $var => $val) {
                                                                                                 // Custom Fields.
                                                                                                 if (!($url = preg_replace('/%%' . preg_quote($var, '/') . '%%/i', c_ws_plugin__s2member_utils_strings::esc_refs(urlencode(maybe_serialize($val))), $url))) {
                                                                                                     break;
                                                                                                 }
                                                                                             }
                                                                                             if ($url = trim($url)) {
                                                                                                 // Preserve remaining Replacements; because the parent routine may perform replacements too.
                                                                                                 $GLOBALS['ws_plugin__s2member_registration_return_url'] = $url;
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                     unset($url, $var, $val);
                                     // Housekeeping.
                                     c_ws_plugin__s2member_list_servers::process_list_servers($role, $level, $login, $pass, $email, $fname, $lname, $ip, $opt_in, TRUE, $user_id);
                                     /*
                                     Suppress errors here in case this routine is fired in unexpected locations; or with odd output buffering techniques.
                                     	@TODO It may also be impossible to delete cookies when fired inside: `/wp-activate.php`.
                                     */
                                     if (!headers_sent()) {
                                         @setcookie('s2member_subscr_gateway', '', time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie('s2member_subscr_gateway', '', time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                                         @setcookie('s2member_subscr_id', '', time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie('s2member_subscr_id', '', time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                                         @setcookie('s2member_custom', '', time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie('s2member_custom', '', time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                                         @setcookie('s2member_item_number', '', time() + 31556926, COOKIEPATH, COOKIE_DOMAIN) . @setcookie('s2member_item_number', '', time() + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
                                     }
                                     /* If debugging/logging is enabled; we need to append ``$reg_vars`` to the log file.
                                     			Logging now supports Multisite Networking as well. */
                                     $reg_vars = get_defined_vars();
                                     // All defined vars.
                                     $reg_vars['_COOKIE'] = $_COOKIE;
                                     // Record cookies also.
                                     // No need to include these in the logs. Unset before log entry.
                                     unset($reg_vars['wpdb'], $reg_vars['current_site'], $reg_vars['current_blog']);
                                     c_ws_plugin__s2member_utils_logs::log_entry('reg-handler', $reg_vars);
                                     foreach (array_keys(get_defined_vars()) as $__v) {
                                         $__refs[$__v] =& ${$__v};
                                     }
                                     do_action('ws_plugin__s2member_during_configure_user_registration', get_defined_vars());
                                     unset($__refs, $__v);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__s2member_after_configure_user_registration', get_defined_vars());
     unset($__refs, $__v);
     // Housekeeping.
 }
 /**
  * Handles login redirections.
  *
  * @package s2Member\Login_Redirects
  * @since 3.5
  *
  * @attaches-to ``add_action("wp_login");``
  *
  * @param str $username Expects Username to be passed in by the Action Hook.
  * @return null Or exits script execution after a redirection takes place.
  */
 public static function login_redirect($username = FALSE)
 {
     eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
     do_action("ws_plugin__s2member_before_login_redirect", get_defined_vars());
     unset($__refs, $__v);
     /* Unset defined __refs, __v. */
     /**/
     $username = !$username && is_object($user = wp_get_current_user()) && !empty($user->user_login) ? strtolower($user->user_login) : strtolower($username);
     /**/
     if ($username && (isset($user) && is_object($user) || is_object($user = new WP_User($username))) && !empty($user->ID) && ($user_id = $user->ID)) {
         if (!get_user_option("s2member_registration_ip", $user_id)) {
             /* Have we got this yet? */
             update_user_option($user_id, "s2member_registration_ip", $_SERVER["REMOTE_ADDR"]);
         }
         /**/
         if (($logins = (int) get_user_option("s2member_login_counter", $user_id) + 1) >= 1 || ($logins = 1)) {
             update_user_option($user_id, "s2member_login_counter", $logins);
         }
         /**/
         if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"]) {
             /* Nag em? */
             delete_user_setting("default_password_nag") . update_user_option($user_id, "default_password_nag", false, true);
         }
         /**/
         $disable_login_ip_restrictions = apply_filters("ws_plugin__s2member_disable_login_ip_restrictions", false, get_defined_vars());
         /**/
         if (($ok = true) && !is_super_admin($user_id) && $username !== "demo" && !$disable_login_ip_restrictions) {
             $ok = c_ws_plugin__s2member_ip_restrictions::ip_restrictions_ok($_SERVER["REMOTE_ADDR"], $username);
         }
         /**/
         if ($redirect = apply_filters("ws_plugin__s2member_login_redirect", $user->has_cap("edit_posts") ? false : true, get_defined_vars())) {
             $obey_redirect_to = apply_filters("ws_plugin__s2member_obey_login_redirect_to", true, get_defined_vars());
             /**/
             if (!$obey_redirect_to || empty($_REQUEST["redirect_to"]) || !is_string($_REQUEST["redirect_to"]) || $_REQUEST["redirect_to"] === admin_url() || preg_match("/^\\/?wp-admin\\/?\$/", $_REQUEST["redirect_to"])) {
                 eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
                 do_action("ws_plugin__s2member_during_login_redirect", get_defined_vars());
                 unset($__refs, $__v);
                 /* Unset defined __refs, __v. */
                 /**/
                 if ($redirect && is_string($redirect)) {
                     /* Is this a string? */
                     wp_redirect($redirect);
                 } else {
                     if ($redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url($user)) {
                         wp_redirect($redirection_url);
                     } else {
                         /* Else we use the Login Welcome Page configured for s2Member. */
                         wp_redirect(get_page_link($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
                     }
                 }
                 /**/
                 exit;
                 /* Clean exit. */
             }
         }
     }
     /**/
     eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
     do_action("ws_plugin__s2member_after_login_redirect", get_defined_vars());
     unset($__refs, $__v);
     /* Unset defined __refs, __v. */
     /**/
     return;
     /* Return for uniformity. */
 }
 /**
  * Handles login redirections.
  *
  * @package s2Member\Login_Redirects
  * @since 3.5
  *
  * @attaches-to ``add_action('wp_login');``
  *
  * @param string  $username Expects Username.
  * @param WP_User $user Expects a WP_User object instance.
  *
  * @return null Or exits script execution after a redirection takes place.
  */
 public static function login_redirect($username = '', $user = NULL)
 {
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__s2member_before_login_redirect', get_defined_vars());
     unset($__refs, $__v);
     // Housekeeping.
     if (is_string($username) && $username && is_object($user) && !empty($user->ID) && ($user_id = $user->ID)) {
         update_user_option($user_id, 's2member_last_login_time', time());
         if (!get_user_option('s2member_registration_ip', $user_id)) {
             update_user_option($user_id, 's2member_registration_ip', $_SERVER['REMOTE_ADDR']);
         }
         if (($logins = (int) get_user_option('s2member_login_counter', $user_id) + 1) >= 1 || ($logins = 1)) {
             update_user_option($user_id, 's2member_login_counter', $logins);
         }
         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['custom_reg_password']) {
             delete_user_setting('default_password_nag') . update_user_option($user_id, 'default_password_nag', FALSE, TRUE);
         }
         if (($ok = TRUE) && !is_super_admin($user_id) && $username !== 'demo' && !apply_filters('ws_plugin__s2member_disable_login_ip_restrictions', $user->has_cap('edit_posts') ? TRUE : FALSE, get_defined_vars())) {
             $ok = c_ws_plugin__s2member_ip_restrictions::ip_restrictions_ok($_SERVER['REMOTE_ADDR'], strtolower($username));
         }
         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_always_http']) {
             // Alter value of `redirect_to`?
             if (!empty($_REQUEST['redirect_to']) && is_string($_REQUEST['redirect_to']) && strpos($_REQUEST['redirect_to'], 'wp-admin') === FALSE) {
                 $_REQUEST['redirect_to'] = preg_replace('/^https\\:\\/\\//i', 'http://', $_REQUEST['redirect_to']);
                 if (stripos($_REQUEST['redirect_to'], 'http://') !== 0) {
                     $home_path = trim((string) @parse_url(home_url('/'), PHP_URL_PATH), '/');
                     $http_home_base = trim(preg_replace('/\\/' . preg_quote($home_path, '/') . '\\/$/', '', home_url('/', 'http')), '/');
                     $_REQUEST['redirect_to'] = $http_home_base . '/' . ltrim($_REQUEST['redirect_to'], '/');
                 }
             }
         }
         if ($redirect = apply_filters('ws_plugin__s2member_login_redirect', $user->has_cap('edit_posts') ? FALSE : TRUE, get_defined_vars())) {
             $obey_redirect_to = apply_filters('ws_plugin__s2member_obey_login_redirect_to', TRUE, get_defined_vars());
             if ($obey_redirect_to && (empty($_REQUEST['redirect_to']) || !is_string($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] === admin_url() || preg_match('/^\\/?wp-admin\\/?$/', $_REQUEST['redirect_to']))) {
                 $obey_redirect_to = FALSE;
             } else {
                 if ($obey_redirect_to && !empty($_REQUEST['redirect_to_automatic']) && is_string($redirect)) {
                     $obey_redirect_to = FALSE;
                 }
             }
             // Do not obey automatic redirects when a custom redirection filter applies.
             // ↑ NOTE: this will apply to s2Member Pro's One-Time-Offers (Upon Login) also.
             if (!$obey_redirect_to) {
                 foreach (array_keys(get_defined_vars()) as $__v) {
                     $__refs[$__v] =& ${$__v};
                 }
                 do_action('ws_plugin__s2member_during_login_redirect', get_defined_vars());
                 unset($__refs, $__v);
                 // Housekeeping.
                 if ($redirect && is_string($redirect)) {
                     $redirect = $redirect;
                 } else {
                     if ($redirection_url = c_ws_plugin__s2member_login_redirects::login_redirection_url($user)) {
                         $redirect = $redirection_url;
                     } else {
                         if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page']) {
                             // Else we use the Login Welcome Page configured for s2Member.
                             $redirect = get_page_link($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_welcome_page']);
                         } else {
                             $redirect = home_url('/');
                         }
                     }
                 }
                 // Default to the home page.
                 if ($GLOBALS['WS_PLUGIN__']['s2member']['o']['login_redirection_always_http']) {
                     $redirect = preg_replace('/^https\\:\\/\\//i', 'http://', $redirect);
                     if (stripos($redirect, 'http://') !== 0) {
                         $home_path = trim((string) @parse_url(home_url('/'), PHP_URL_PATH), '/');
                         $http_home_base = trim(preg_replace('/\\/' . preg_quote($home_path, '/') . '\\/$/', '', home_url('/', 'http')), '/');
                         $redirect = $http_home_base . '/' . ltrim($redirect, '/');
                     }
                 }
                 wp_redirect($redirect) . exit;
             }
         }
     }
     foreach (array_keys(get_defined_vars()) as $__v) {
         $__refs[$__v] =& ${$__v};
     }
     do_action('ws_plugin__s2member_after_login_redirect', get_defined_vars());
     unset($__refs, $__v);
     // Housekeeping.
 }
Exemple #13
0
function bizzthemes_default_layouts($default_action = '')
{
    global $wpdb, $default_layouts_array, $themeid;
    if (isset($default_action) && $default_action == 'reset') {
        # RESET ALL
        // reset sidebars
        // update_option( 'sidebars_widgets', NULL );
        delete_option($themeid . '_sidebars_widgets');
        // updated defaults option
        delete_option('bizz_defaults_' . $themeid);
        // reset all option
        update_option('bizz_reset_' . $themeid, true);
        // delete pointer notice removal
        delete_user_setting('p_empty_widgets_' . str_replace('-', '', $themeid));
        // reset widgets & grids
        $query = "DELETE FROM {$wpdb->posts} WHERE post_type LIKE 'bizz_widget' OR post_type LIKE 'bizz_grid' AND post_content_filtered = '{$themeid}' ";
        $wpdb->query($query);
    } elseif (isset($default_action) && $default_action == 'set_defaults') {
        # SET DEFAULT GRIDS and WIDGETS
        // read options
        $new_options = $default_layouts_array;
        // remove BOM
        $new_options = mb_convert_encoding($new_options, 'UTF-8', 'ASCII,UTF-8,ISO-8859-1');
        if (substr($new_options, 0, 3) == pack("CCC", 0xef, 0xbb, 0xbf)) {
            $new_options = substr($new_options, 3);
        }
        // decode
        $new_options = json_decode($new_options, true);
        $new_all_widgets = $new_options['options_value']['all_widgets'];
        $new_sidebars_widgets = $new_options['options_value']['sidebars_widgets'];
        // $new_sidebars_widgets 	= $new_options['options_value']['sidebars_widgets'][0]['option_value'];
        $new_widget_posts = isset($new_options['options_value']['widget_posts']) ? $new_options['options_value']['widget_posts'] : array();
        $new_grid_posts = isset($new_options['options_value']['grid_posts']) ? $new_options['options_value']['grid_posts'] : array();
        // reset old grids
        $query = "DELETE FROM {$wpdb->posts} WHERE post_type LIKE 'bizz_grid' OR post_type LIKE 'bizz_widget' AND post_content_filtered = '{$themeid}' ";
        $wpdb->query($query);
        // reset backed up widgets
        delete_option($themeid . '_sidebars_widgets');
        // update defaults option
        update_option('bizz_defaults_' . $themeid, true);
        // update widgets
        // bizz_update_widgets($new_sidebars_widgets, $new_all_widgets);
        // update posts
        bizzthemes_update_options('set_new', $new_all_widgets);
        bizzthemes_update_options('set_new', $new_sidebars_widgets);
        bizzthemes_insert_posts('set_new', array_merge($new_widget_posts, $new_grid_posts));
        // update posts
        bizzthemes_insert_posts('set_new', array_merge($new_widget_posts, $new_grid_posts));
    }
}
Exemple #14
0
function pie_register_user_notification($user_id)
{
    $user = new WP_User($user_id);
    #-- PIE REGESTER --#
    global $wpdb, $pie_register;
    $piereg = get_option('pie_register');
    $piereg_custom = get_option('pie_register_custom');
    $ref = explode('?', $_SERVER['HTTP_REFERER']);
    $ref = $ref[0];
    $admin = trailingslashit(get_option('siteurl')) . 'wp-admin/user-new.php';
    if (!is_array($piereg_custom)) {
        $piereg_custom = array();
    }
    if ($piereg['password'] && !empty($_POST['user_pw'])) {
        $plaintext_pass = $_POST['user_pw'];
    } else {
        // otherwise use the supplied password
        $plaintext_pass = $pie_register->RanPass(6);
    }
    if ($piereg['firstname'] && $_POST['firstname']) {
        update_usermeta($user_id, 'first_name', $_POST['firstname']);
    }
    if ($piereg['lastname'] && $_POST['lastname']) {
        update_usermeta($user_id, 'last_name', $_POST['lastname']);
    }
    if ($piereg['website'] && $_POST['website']) {
        update_usermeta($user_id, 'user_url', $_POST['website']);
    }
    if ($piereg['aim'] && $_POST['aim']) {
        update_usermeta($user_id, 'aim', $_POST['aim']);
    }
    if ($piereg['yahoo'] && $_POST['yahoo']) {
        update_usermeta($user_id, 'yim', $_POST['yahoo']);
    }
    if ($piereg['jabber'] && $_POST['jabber']) {
        update_usermeta($user_id, 'jabber', $_POST['jabber']);
    }
    if ($piereg['phone'] && $_POST['phone']) {
        update_usermeta($user_id, 'phone', $_POST['phone']);
    }
    if ($piereg['about'] && $_POST['about']) {
        update_usermeta($user_id, 'description', $_POST['about']);
    }
    if ($piereg['code'] && $_POST['regcode']) {
        update_usermeta($user_id, 'invite_code', $_POST['regcode']);
    }
    if ($ref != $admin && $piereg['admin_verify']) {
        update_usermeta($user_id, 'admin_verify_user', $user->user_login);
        update_usermeta($user_id, 'email_verify_user_pwd', $user->user_pass);
        update_usermeta($user_id, 'email_verify_email', $user->user_email);
        $temp_id = 'unverified__' . $pie_register->RanPass(7);
        $notice = __('Your account requires activation by an administrator before you will be able to login.', 'piereg') . "\r\n";
    } else {
        if ($ref != $admin && $piereg['email_verify']) {
            $code = $pie_register->RanPass(25);
            update_usermeta($user_id, 'email_verify', $code);
            update_usermeta($user_id, 'email_verify_date', date('Ymd'));
            update_usermeta($user_id, 'email_verify_user', $user->user_login);
            update_usermeta($user_id, 'email_verify_user_pwd', $user->user_pass);
            update_usermeta($user_id, 'email_verify_email', $user->user_email);
            $email_code = '?piereg_verification=' . $code . '&';
            $prelink = __('Verification URL: ', 'piereg');
            $notice = __('Please use the link above to verify and activate your account', 'piereg') . "\r\n";
            $temp_id = 'unverified__' . $pie_register->RanPass(7);
            delete_user_setting('default_password_nag', $user_id);
            update_user_option($user_id, 'default_password_nag', false, true);
        } else {
            if ($ref != $admin && $piereg['paypal_option']) {
                $code = $pie_register->RanPass(25);
                update_usermeta($user_id, 'email_verify', $code);
                update_usermeta($user_id, 'pending_payment', 'yes');
                update_usermeta($user_id, 'email_verify_user', $user->user_login);
                update_usermeta($user_id, 'email_verify_user_pwd', $user->user_pass);
                update_usermeta($user_id, 'email_verify_email', $user->user_email);
                $temp_id = 'unverified__' . $pie_register->RanPass(7);
                $email_code = '?piereg_verification=' . $code . '&';
                $prelink = __('Verification URL: ', 'piereg');
                $notice = __('Please click on the above link to verify your email', 'piereg') . "\r\n";
            }
        }
    }
    if (!empty($piereg_custom)) {
        foreach ($piereg_custom as $k => $v) {
            $id = $pie_register->Label_ID($v['label']);
            if ($v['reg'] && $_POST[$id]) {
                if (is_array($_POST[$id])) {
                    $_POST[$id] = implode(', ', $_POST[$id]);
                }
                update_usermeta($user_id, $id, $_POST[$id]);
            }
        }
    }
    #-- END Pie Rgister --#
    wp_set_password($plaintext_pass, $user_id);
    $user_login = stripslashes($user->user_login);
    $user_email = stripslashes($user->user_email);
    #-- Pie-Register --#
    if (!$piereg['custom_adminmsg'] && !$piereg['disable_admin']) {
        #-- END Pie-Register --#
        $message = sprintf(__('New user Register on your blog %s:', 'piereg'), get_option('blogname')) . "\r\n\r\n";
        $message .= sprintf(__('Username: %s', 'piereg'), $user_login) . "\r\n\r\n";
        $message .= sprintf(__('E-mail: %s', 'piereg'), $user_email) . "\r\n";
        @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Register', 'piereg'), get_option('blogname')), $message);
        #-- Pie-Register --#
    } else {
        if (!$piereg['disable_admin']) {
            if ($piereg['adminhtml']) {
                $headers = 'MIME-Version: 1.0' . "\r\n";
                $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
            }
            //$headers .= 'From: ' . $piereg['adminfrom'] . "\r\n" . 'Reply-To: ' . $piereg['adminfrom'] . "\r\n";
            add_filter('wp_mail_from', array($pie_register, 'adminfrom'));
            add_filter('wp_mail_from_name', array($pie_register, 'adminfromname'));
            $subject = $piereg['adminsubject'];
            $message = str_replace('%user_login%', $user_login, $piereg['adminmsg']);
            $message = str_replace('%user_email%', $user_email, $message);
            $message = str_replace('%blogname%', get_option('blogname'), $message);
            $message = str_replace('%user_ip%', $_SERVER['REMOTE_ADDR'], $message);
            $message = str_replace('%user_host%', gethostbyaddr($_SERVER['REMOTE_ADDR']), $message);
            $message = str_replace('%user_ref%', $_SERVER['HTTP_REFERER'], $message);
            $message = str_replace('%user_agent%', $_SERVER['HTTP_USER_AGENT'], $message);
            if ($piereg['firstname']) {
                $message = str_replace('%firstname%', $_POST['firstname'], $message);
            }
            if ($piereg['lastname']) {
                $message = str_replace('%lastname%', $_POST['lastname'], $message);
            }
            if ($piereg['website']) {
                $message = str_replace('%website%', $_POST['website'], $message);
            }
            if ($piereg['aim']) {
                $message = str_replace('%aim%', $_POST['aim'], $message);
            }
            if ($piereg['yahoo']) {
                $message = str_replace('%yahoo%', $_POST['yahoo'], $message);
            }
            if ($piereg['jabber']) {
                $message = str_replace('%jabber%', $_POST['jabber'], $message);
            }
            if ($piereg['phone']) {
                $message = str_replace('%phone%', $_POST['phone'], $message);
            }
            if ($piereg['about']) {
                $message = str_replace('%about%', $_POST['about'], $message);
            }
            if ($piereg['code']) {
                $message = str_replace('%' . $piereg['codename'] . 'code%', $_POST['regcode'], $message);
            }
            if (!is_array($piereg_custom)) {
                $piereg_custom = array();
            }
            if (!empty($piereg_custom)) {
                foreach ($piereg_custom as $k => $v) {
                    $meta = $pie_register->Label_ID($v['label']);
                    $value = get_user_meta($user_id, $meta, true);
                    $message = str_replace('%' . $meta . '%', $value, $message);
                }
            }
            $siteurl = get_option('siteurl');
            $message = str_replace('%siteurl%', $siteurl, $message);
            if ($piereg['adminhtml'] && $piereg['admin_nl2br']) {
                $message = nl2br($message);
            }
            wp_mail(get_option('admin_email'), $subject, $message, $headers);
        }
    }
    #-- END Pie-Register --#
    if (empty($plaintext_pass)) {
        return;
    }
    #-- Pie-Register --#
    if (!$piereg['custom_msg']) {
        #-- END Pie-Register --#
        $message = sprintf(__('Username: %s', 'piereg'), $user_login) . "\r\n";
        $message .= sprintf(__('Password: %s', 'piereg'), $plaintext_pass) . "\r\n";
        //$message .= get_option('siteurl') . "/wp-login.php";
        #-- Pie-Register --#
        $message .= $email_code ? $prelink . get_option('siteurl') . "/wp-login.php" . $email_code . "\r\n" : "-xxx-";
        $message .= $notice;
        #-- END Pie-Register --#
        wp_mail($user_email, sprintf(__('[%s] Your username and password', 'piereg'), get_option('blogname')), $message);
        #-- Pie-Register --#
    } else {
        $unvemailcheck = get_user_meta($user_id, 'email_verify_email', true);
        if ($unvemailcheck && $piereg['emailvmsghtml'] || $unvemailcheck && $piereg['adminvmsghtml'] || !$unvemailcheck && $piereg['html']) {
            $headers = 'MIME-Version: 1.0' . "\r\n";
            $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        }
        //$headers .= 'From: ' . $piereg['from'] . "\r\n" . 'Reply-To: ' . $piereg['from'] . "\r\n";
        add_filter('wp_mail_from', array($pie_register, 'userfrom'));
        add_filter('wp_mail_from_name', array($pie_register, 'userfromname'));
        $subject = $piereg['subject'];
        //Here we need to put the PENDING VERIFICATION EMAIL
        //Email Verification
        if ($unvemailcheck && $piereg['email_verify']) {
            $message = str_replace('%user_pass%', $plaintext_pass, $piereg['emailvmsg']);
        } else {
            if ($unvemailcheck && $piereg['admin_verify']) {
                //Admin Verification
                $message = str_replace('%user_pass%', $plaintext_pass, $piereg['adminvmsg']);
            } else {
                //Confirmed User Message
                $message = str_replace('%user_pass%', $plaintext_pass, $piereg['msg']);
            }
        }
        $message = str_replace('%user_login%', $user_login, $message);
        $message = str_replace('%user_email%', $user_email, $message);
        $message = str_replace('%blogname%', get_option('blogname'), $message);
        $message = str_replace('%user_ip%', $_SERVER['REMOTE_ADDR'], $message);
        $message = str_replace('%user_host%', gethostbyaddr($_SERVER['REMOTE_ADDR']), $message);
        $message = str_replace('%user_ref%', $_SERVER['HTTP_REFERER'], $message);
        $message = str_replace('%user_agent%', $_SERVER['HTTP_USER_AGENT'], $message);
        if ($piereg['firstname']) {
            $message = str_replace('%firstname%', $_POST['firstname'], $message);
        }
        if ($piereg['lastname']) {
            $message = str_replace('%lastname%', $_POST['lastname'], $message);
        }
        if ($piereg['website']) {
            $message = str_replace('%website%', $_POST['website'], $message);
        }
        if ($piereg['aim']) {
            $message = str_replace('%aim%', $_POST['aim'], $message);
        }
        if ($piereg['yahoo']) {
            $message = str_replace('%yahoo%', $_POST['yahoo'], $message);
        }
        if ($piereg['jabber']) {
            $message = str_replace('%jabber%', $_POST['jabber'], $message);
        }
        if ($piereg['phone']) {
            $message = str_replace('%phone%', $_POST['phone'], $message);
        }
        if ($piereg['about']) {
            $message = str_replace('%about%', $_POST['about'], $message);
        }
        if ($piereg['code']) {
            $message = str_replace('%' . $piereg['codename'] . 'code%', $_POST['regcode'], $message);
        }
        if (!is_array($piereg_custom)) {
            $piereg_custom = array();
        }
        if (!empty($piereg_custom)) {
            foreach ($piereg_custom as $k => $v) {
                $meta = $pie_register->Label_ID($v['label']);
                $value = get_user_meta($user_id, $meta, true);
                $message = str_replace('%' . $meta . '%', $value, $message);
            }
        }
        $redirect = 'redirect_to=' . $piereg['login_redirect'];
        if ($piereg['email_verify'] && !$piereg['paypal_option']) {
            $siteurl = get_option('siteurl') . "/wp-login.php" . $email_code . $redirect;
        } else {
            if ($piereg['paypal_option']) {
                $siteurl = get_option('siteurl') . "/wp-login.php" . $email_code;
            } else {
                $siteurl = get_option('siteurl') . "/wp-login.php?" . $redirect;
            }
        }
        $message = str_replace('%siteurl%', $siteurl, $message);
        //Email Verification
        if ($unvemailcheck && $piereg['email_verify'] && $piereg['emailvhtml'] && $piereg['emailvuser_nl2br']) {
            $message = nl2br($message);
        } else {
            if ($unvemailcheck && $piereg['admin_verify'] && $piereg['adminvhtml'] && $piereg['adminvuser_nl2br']) {
                $message = nl2br($message);
            } else {
                if ($piereg['html'] && $piereg['user_nl2br']) {
                    $message = nl2br($message);
                }
            }
        }
        wp_mail($user_email, $subject, $message, $headers);
    }
    if ($ref != $admin && ($piereg['email_verify'] || $piereg['admin_verify'])) {
        $temp_user = $wpdb->query("UPDATE {$wpdb->users} SET user_login = '******' WHERE ID = '{$user_id}'");
    } else {
        if ($ref != $admin && $piereg['paypal_option']) {
            $temp_user = $wpdb->query("UPDATE {$wpdb->users} SET user_login = '******' WHERE ID = '{$user_id}'");
            $temp_email = $wpdb->query("UPDATE {$wpdb->users} SET user_email = '{$temp_id_}" . $user_email . "' WHERE ID = '{$user_id}'");
            //$wpdb->query( "UPDATE $wpdb->users SET user_email = '$user_email_$temp_id' WHERE ID = '$user_id'" );
        }
    }
    if (!is_admin()) {
        wp_safe_redirect('wp-login.php?checkemail=registered');
        exit;
    }
    return $user_id;
}
Exemple #15
0
 /**
  * Deleting settings would reset them to the defaults. 
  * This function has to be used before any output has started as it calls setcookie()
  * 
  * @return void
  */
 function delete_user_setting()
 {
     if (isset($_GET['ngg_restart_tour'])) {
         delete_user_setting('nextgen_tour_pointer');
     }
 }