| 1 |
<?php |
| 2 |
// @codingStandardsIgnoreFile |
| 3 |
/** |
| 4 |
* Users list (inner processing routines). |
| 5 |
* |
| 6 |
* Copyright: © 2009-2011 |
| 7 |
* {@link http://websharks-inc.com/ WebSharks, Inc.} |
| 8 |
* (coded in the USA) |
| 9 |
* |
| 10 |
* Released under the terms of the GNU General Public License. |
| 11 |
* You should have received a copy of the GNU General Public License, |
| 12 |
* along with this software. In the main directory, see: /licensing/ |
| 13 |
* If not, see: {@link http://www.gnu.org/licenses/}. |
| 14 |
* |
| 15 |
* @package s2Member\Users_List |
| 16 |
* @since 3.5 |
| 17 |
*/ |
| 18 |
if(!defined('WPINC')) // MUST have WordPress. |
| 19 |
exit("Do not access this file directly."); |
| 20 |
|
| 21 |
if(!class_exists("c_ws_plugin__s2member_users_list_in")) |
| 22 |
{ |
| 23 |
/** |
| 24 |
* Users list (inner processing routines). |
| 25 |
* |
| 26 |
* @package s2Member\Users_List |
| 27 |
* @since 3.5 |
| 28 |
*/ |
| 29 |
class c_ws_plugin__s2member_users_list_in |
| 30 |
{ |
| 31 |
/** |
| 32 |
* Adds Custom Fields to the admin Profile editing page. |
| 33 |
* |
| 34 |
* @package s2Member\Users_List |
| 35 |
* @since 3.5 |
| 36 |
* |
| 37 |
* @attaches-to ``add_action("edit_user_profile");`` |
| 38 |
* @attaches-to ``add_action("show_user_profile");`` |
| 39 |
* |
| 40 |
* @param $user \WP_User Expects a `WP_User` object passed in by the Action Hook. |
| 41 |
*/ |
| 42 |
public static function users_list_edit_cols($user = NULL) |
| 43 |
{ |
| 44 |
global $current_site, $current_blog; // Multisite networks. |
| 45 |
|
| 46 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 47 |
do_action("ws_plugin__s2member_before_users_list_edit_cols", get_defined_vars()); |
| 48 |
unset($__refs, $__v); |
| 49 |
|
| 50 |
$current_user = is_user_logged_in() ? wp_get_current_user() : FALSE; // Current User. |
| 51 |
|
| 52 |
if(is_object($user) && !empty($user->ID) && ($user_id = $user->ID) && is_object($current_user) && !empty($current_user->ID)) |
| 53 |
{ |
| 54 |
$role = c_ws_plugin__s2member_user_access::user_access_role($user); // This User's current WordPress Role. |
| 55 |
$level = c_ws_plugin__s2member_user_access::user_access_level($user); // User's Access Level for s2Member. |
| 56 |
|
| 57 |
if(current_user_can("edit_users") && (!is_multisite() || is_super_admin() || is_user_member_of_blog($user_id))) |
| 58 |
{ |
| 59 |
echo '<div style="margin:25px 0 25px 0; height:1px; line-height:1px; background:#CCCCCC;"></div>'."\n"; |
| 60 |
|
| 61 |
echo '<h3 style="position:relative;"><img src="'.esc_attr($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"]).'/src/images/large-icon.png" title="s2Member (a Membership management system for WordPress)" alt="" style="position:absolute; top:-15px; right:0; border:0;" />s2Member Configuration & Profile Fields'.((is_multisite()) ? ' (for this Blog)' : '').'</h3>'."\n"; |
| 62 |
|
| 63 |
echo '<table class="form-table">'."\n"; |
| 64 |
|
| 65 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 66 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_before", get_defined_vars()); |
| 67 |
unset($__refs, $__v); |
| 68 |
|
| 69 |
if(is_multisite() && is_super_admin()) // Super Admins can edit this. |
| 70 |
{ |
| 71 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 72 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_before_originating_blog", get_defined_vars()); |
| 73 |
unset($__refs, $__v); |
| 74 |
|
| 75 |
echo '<tr>'."\n"; |
| 76 |
echo '<th><label for="ws-plugin--s2member-profile-s2member-originating-blog">Originating Blog ID#:</label> <a href="#" onclick="alert(\'On a Multisite Network, this is how s2Member keeps track of which Blog each User/Member originated from. So this ID#, is automatically associated with a Blog in your Network, matching the User\\\'s point of origin. ~ ONLY a Super Admin can modify this.\\n\\nOn a Multisite Blog Farm, the Originating Blog ID# for your own Customers, will ALWAYS be associated with your (Main Site). It is NOT likely that you\\\'ll need to modify this manually, but s2Member makes it available; just in case.\\n\\n*Tip* - If you add Users (and/or Blogs) with the `Super Admin` Network Administration panel inside WordPress, then you WILL need to set everything manually. s2Member does NOT tamper with automation routines whenever YOU (as a Super Administrator) are working in that area.\'); return false;" tabindex="-1">[?]</a></th>'."\n"; |
| 77 |
echo '<td><input type="text" autocomplete="off" name="ws_plugin__s2member_profile_s2member_originating_blog" id="ws-plugin--s2member-profile-s2member-originating-blog" value="'.format_to_edit(get_user_meta($user_id, "s2member_originating_blog", TRUE)).'" class="regular-text" /></td>'."\n"; |
| 78 |
echo '</tr>'."\n"; |
| 79 |
|
| 80 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 81 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_after_originating_blog", get_defined_vars()); |
| 82 |
unset($__refs, $__v); |
| 83 |
} |
| 84 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 85 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_before_subscr_gateway", get_defined_vars()); |
| 86 |
unset($__refs, $__v); |
| 87 |
|
| 88 |
echo '<tr>'."\n"; |
| 89 |
echo '<th><label for="ws-plugin--s2member-profile-s2member-subscr-gateway">Paid Subscr. Gateway:</label> <a href="#" onclick="alert(\'A Payment Gateway Code is associated with the Paid Subscr. ID below. A Paid Subscription ID (or a Buy Now Transaction ID) is only valid for paid Members. Also known as a Recurring Profile ID, a ClickBank Receipt #, a Google Order ID, an AliPay Trade No.\\n\\nThis will be filled automatically by s2Member. This field will be empty for Free Subscribers, and/or anyone who is NOT paying you. This field is only editable for Customer Service purposes; just in case you ever need to update the Paid Subscr. Gateway/ID manually.\\n\\nThe value of Paid Subscr. ID can be a PayPal Standard Subscription ID, or a PayPal Pro Recurring Profile ID, or a PayPal Transaction ID; depending on the type of sale. Your PayPal account will supply this information.\\n\\nIf you are using Stripe, please use the customer\\\'s Subscription ID (if applicable); else a Charge ID or an Invoice ID.\\n\\nIf you\\\'re using Google Wallet, use the Google Order ID. ClickBank provides a Receipt #, ccBill provides a Subscription ID, Authorize.Net provides a Subscription ID, and AliPay provides a Transaction ID.\\n\\nThe general rule is... IF there\\\'s a Subscription ID, use that! If there\\\'s NOT, use the Transaction ID.\'); return false;" tabindex="-1">[?]</a></th>'."\n"; |
| 90 |
echo '<td><select name="ws_plugin__s2member_profile_s2member_subscr_gateway" id="ws-plugin--s2member-profile-s2member-subscr-gateway" style="width:25em;"><option value=""></option>'."\n"; |
| 91 |
foreach(apply_filters("ws_plugin__s2member_profile_s2member_subscr_gateways", array("paypal" => "PayPal (code: paypal)"), get_defined_vars()) as $gateway => $gateway_name) |
| 92 |
echo '<option value="'.esc_attr($gateway).'"'.(($gateway === get_user_option("s2member_subscr_gateway", $user_id)) ? ' selected="selected"' : '').'>'.esc_html($gateway_name).'</option>'."\n"; |
| 93 |
echo '</select>'."\n"; |
| 94 |
echo '</td>'."\n"; |
| 95 |
echo '</tr>'."\n"; |
| 96 |
|
| 97 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 98 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_after_subscr_gateway", get_defined_vars()); |
| 99 |
unset($__refs, $__v); |
| 100 |
|
| 101 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 102 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_before_subscr_id", get_defined_vars()); |
| 103 |
unset($__refs, $__v); |
| 104 |
|
| 105 |
echo '<tr>'."\n"; |
| 106 |
echo '<th><label for="ws-plugin--s2member-profile-s2member-subscr-id">Paid Subscr. ID:</label> <a href="#" onclick="alert(\'A Paid Subscription ID (or a Buy Now Transaction ID) is only valid for paid Members. Also known as a Recurring Profile ID, a ClickBank Receipt #, a Google Order ID, an AliPay Trade No.\\n\\nThis will be filled automatically by s2Member. This field will be empty for Free Subscribers, and/or anyone who is NOT paying you. This field is only editable for Customer Service purposes; just in case you ever need to update the Paid Subscr. Gateway/ID manually.\\n\\nThe value of Paid Subscr. ID can be a PayPal Standard Subscription ID, or a PayPal Pro Recurring Profile ID, or a PayPal Transaction ID; depending on the type of sale. Your PayPal account will supply this information.\\n\\nIf you are using Stripe, please use the customer\\\'s Subscription ID (if applicable); else a Charge ID or an Invoice ID.\\n\\nIf you\\\'re using Google Wallet, use the Google Order ID. ClickBank provides a Receipt #, ccBill provides a Subscription ID, Authorize.Net provides a Subscription ID, and AliPay provides a Transaction ID.\\n\\nThe general rule is... IF there\\\'s a Subscription ID, use that! If there\\\'s NOT, use the Transaction ID.\'); return false;" tabindex="-1">[?]</a></th>'."\n"; |
| 107 |
echo '<td><input type="text" autocomplete="off" name="ws_plugin__s2member_profile_s2member_subscr_id" id="ws-plugin--s2member-profile-s2member-subscr-id" value="'.format_to_edit(get_user_option("s2member_subscr_id", $user_id)).'" class="regular-text" /></td>'."\n"; |
| 108 |
echo '</tr>'."\n"; |
| 109 |
|
| 110 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 111 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_after_subscr_id", get_defined_vars()); |
| 112 |
unset($__refs, $__v); |
| 113 |
|
| 114 |
if(c_ws_plugin__s2member_utils_conds::pro_is_installed()) |
| 115 |
if(in_array('stripe', $GLOBALS['WS_PLUGIN__']['s2member']['o']['pro_gateways_enabled'])) |
| 116 |
{ |
| 117 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 118 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_before_subscr_cid", get_defined_vars()); |
| 119 |
unset($__refs, $__v); |
| 120 |
|
| 121 |
echo '<tr>'."\n"; |
| 122 |
echo '<th><label for="ws-plugin--s2member-profile-s2member-subscr-cid">Paid Subscr. CID:</label> <a href="#" onclick="alert(\'A Paid Subscription CID; i.e., a Customer\\\'s ID. Applicable only with Stripe integration. s2Member fills this in automatically. This is the Customer\\\'s ID in Stripe, which remains constant throughout any & all future payments. Each Stripe Customer has this Customer ID; and also a Subscription and/or Transaction ID.\\n\\nIn all other cases, the Paid Subscr. CID is simply set to the Paid Subscr. ID value; i.e., it is a duplicate of Paid Subscr. ID when running anything other than Stripe.\\n\\nThis field will be empty for Free Subscribers, and/or anyone who is NOT paying you. This field is only editable for Customer Service purposes; just in case you ever need to update the Paid Subscr. Gateway/ID/CID manually.\'); return false;" tabindex="-1">[?]</a></th>'."\n"; |
| 123 |
echo '<td><input type="text" autocomplete="off" name="ws_plugin__s2member_profile_s2member_subscr_cid" id="ws-plugin--s2member-profile-s2member-subscr-cid" value="'.format_to_edit(get_user_option("s2member_subscr_cid", $user_id)).'" class="regular-text" /></td>'."\n"; |
| 124 |
echo '</tr>'."\n"; |
| 125 |
|
| 126 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 127 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_after_subscr_cid", get_defined_vars()); |
| 128 |
unset($__refs, $__v); |
| 129 |
} |
| 130 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 131 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_before_custom", get_defined_vars()); |
| 132 |
unset($__refs, $__v); |
| 133 |
|
| 134 |
echo '<tr>'."\n"; |
| 135 |
echo '<th><label for="ws-plugin--s2member-profile-s2member-custom">Custom Value:</label> <a href="#" onclick="alert(\'A Paid Subscription is always associated with a Custom String that is passed through the custom=\\\'\\\''.c_ws_plugin__s2member_utils_strings::esc_js_sq(esc_attr($_SERVER["HTTP_HOST"]), 3).'\\\'\\\' attribute of your Shortcode. This Custom Value, MUST always start with your domain name. However, you can also pipe delimit additional values after your domain, if you need to.\\n\\nFor example:\n'.c_ws_plugin__s2member_utils_strings::esc_js_sq(esc_attr($_SERVER["HTTP_HOST"]), 3).'|cv1|cv2|cv3\'); return false;" tabindex="-1">[?]</a></th>'."\n"; |
| 136 |
echo '<td><input type="text" autocomplete="off" name="ws_plugin__s2member_profile_s2member_custom" id="ws-plugin--s2member-profile-s2member-custom" value="'.format_to_edit(get_user_option("s2member_custom", $user_id)).'" class="regular-text" /></td>'."\n"; |
| 137 |
echo '</tr>'."\n"; |
| 138 |
|
| 139 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 140 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_after_custom", get_defined_vars()); |
| 141 |
unset($__refs, $__v); |
| 142 |
|
| 143 |
if(c_ws_plugin__s2member_utils_conds::pro_is_installed()) |
| 144 |
{ |
| 145 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 146 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_before_coupon_codes", get_defined_vars()); |
| 147 |
unset($__refs, $__v); |
| 148 |
|
| 149 |
echo '<tr>'."\n"; |
| 150 |
echo '<th><label for="ws-plugin--s2member-profile-s2member-coupon-codes">Coupon Code(s):</label> <a href="#" onclick="alert(\'This is a comma-delimited list of the Coupon Codes associated with this user; i.e., the Coupon Code(s) that have been used to complete checkout. s2Member updates this list automatically. This field is only editable for Customer Service purposes; i.e., just in case you ever need to update the list manually.\'); return false;" tabindex="-1">[?]</a></th>'."\n"; |
| 151 |
echo '<td><input type="text" autocomplete="off" name="ws_plugin__s2member_profile_s2member_coupon_codes" id="ws-plugin--s2member-profile-s2member-coupon-codes" value="'.format_to_edit(implode(',', is_array($_user_coupon_codes = get_user_option("s2member_coupon_codes", $user_id)) ? $_user_coupon_codes : array())).'" class="regular-text" /></td>'."\n"; |
| 152 |
echo '</tr>'."\n"; |
| 153 |
|
| 154 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 155 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_after_coupon_codes", get_defined_vars()); |
| 156 |
unset($__refs, $__v); |
| 157 |
} |
| 158 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 159 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_before_registration_ip", get_defined_vars()); |
| 160 |
unset($__refs, $__v); |
| 161 |
|
| 162 |
echo '<tr>'."\n"; |
| 163 |
echo '<th><label for="ws-plugin--s2member-profile-s2member-registration-ip">Registration IP:</label> <a href="#" onclick="alert(\'This is the IP Address the User had at the time of registration. If you don\\\'t know the User\\\'s IP Address, just leave this blank. If this is left empty, s2Member will make attempts in the future to grab the User\\\'s IP Address.\'); return false;" tabindex="-1">[?]</a></th>'."\n"; |
| 164 |
echo '<td><input type="text" autocomplete="off" name="ws_plugin__s2member_profile_s2member_registration_ip" id="ws-plugin--s2member-profile-s2member-registration-ip" value="'.format_to_edit(get_user_option("s2member_registration_ip", $user_id)).'" class="regular-text" /></td>'."\n"; |
| 165 |
echo '</tr>'."\n"; |
| 166 |
|
| 167 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 168 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_after_registration_ip", get_defined_vars()); |
| 169 |
unset($__refs, $__v); |
| 170 |
|
| 171 |
if(!is_multisite() || !c_ws_plugin__s2member_utils_conds::is_multisite_farm() || is_main_site()) // Will change once Custom Capabilities are compatible with a Blog Farm. |
| 172 |
{ |
| 173 |
foreach($user->allcaps as $cap => $cap_enabled) |
| 174 |
if(preg_match("/^access_s2member_ccap_/", $cap)) |
| 175 |
$ccaps[] = preg_replace("/^access_s2member_ccap_/", "", $cap); |
| 176 |
|
| 177 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 178 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_before_ccaps", get_defined_vars()); |
| 179 |
unset($__refs, $__v); |
| 180 |
|
| 181 |
echo '<tr>'."\n"; |
| 182 |
echo '<th><label for="ws-plugin--s2member-profile-s2member-ccaps">Custom Capabilities:</label> <a href="#" onclick="alert(\'Optional. This is VERY advanced.\\nSee: s2Member → API Scripting → Custom Capabilities.'.((is_multisite()) ? '\\n\\nCustom Capabilities are assigned on a per-Blog basis. So having a set of Custom Capabilities for one Blog, and having NO Custom Capabilities on another Blog - is very common. This is how permissions are designed to work.' : '').'\'); return false;" tabindex="-1">[?]</a>'.((is_multisite()) ? '<br /><small>(for this Blog)</small>' : '').'</th>'."\n"; |
| 183 |
echo '<td><input type="text" autocomplete="off" name="ws_plugin__s2member_profile_s2member_ccaps" id="ws-plugin--s2member-profile-s2member-ccaps" value="'.format_to_edit(((!empty($ccaps)) ? implode(",", $ccaps) : "")).'" class="regular-text" onkeyup="if(this.value.match(/[^a-z_0-9,]/)) this.value = jQuery.trim (jQuery.trim (this.value).replace (/[ \-]/g, \'_\').replace (/[^a-z_0-9,]/gi, \'\').toLowerCase ());" /></td>'."\n"; |
| 184 |
echo '</tr>'."\n"; |
| 185 |
|
| 186 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 187 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_after_ccaps", get_defined_vars()); |
| 188 |
unset($__refs, $__v); |
| 189 |
} |
| 190 |
if(!$user->has_cap("administrator")) // Do NOT present these details for Administrator accounts. |
| 191 |
{ |
| 192 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 193 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_before_auto_eot_time", get_defined_vars()); |
| 194 |
unset($__refs, $__v); |
| 195 |
|
| 196 |
echo '<tr>'."\n"; |
| 197 |
$auto_eot_time = get_user_option("s2member_auto_eot_time", $user_id); |
| 198 |
if($auto_eot_time && !is_numeric($auto_eot_time)) $auto_eot_time = strtotime((string)$auto_eot_time); //260219 |
| 199 |
$auto_eot_time = ($auto_eot_time) ? date("D M j, Y g:i a T", (int)$auto_eot_time) : ""; |
| 200 |
echo '<th><label for="ws-plugin--s2member-profile-s2member-auto-eot-time">Automatic EOT Time:</label> <a href="#" onclick="alert(\'EOT = End Of Term. ( i.e., Account Expiration / Termination. ).\\n\\nIf you leave this empty, s2Member will configure an EOT Time automatically, based on the paid Subscription associated with this account. In other words, if a paid Subscription expires, is cancelled, terminated, refunded, reversed, or charged back to you; s2Member will deal with the EOT automatically.\\n\\nThat being said, if you would rather take control over this, you can. If you type in a date manually, s2Member will obey the Auto-EOT Time that you\\\'ve given, no matter what. In other words, you can force certain Members to expire automatically, at a time that you specify. s2Member will obey.\\n\\nValid formats for Automatic EOT Time:\\n\\nmm/dd/yyyy\\nyyyy-mm-dd\\n+1 year\\n+2 weeks\\n+2 months\\n+10 minutes\\nnext thursday\\ntomorrow\\ntoday\\n\\n* anything compatible with PHP\\\'s strtotime() function.\'); return false;" tabindex="-1">[?]</a>'.(($auto_eot_time) ? '<br /><small>(<a href="https://en.wikipedia.org/wiki/Coordinated_Universal_Time" target="_blank" rel="external">Universal Time / GMT</a>)</small>' : '').'</th>'."\n"; |
| 201 |
echo '<td><input type="text" autocomplete="off" name="ws_plugin__s2member_profile_s2member_auto_eot_time" id="ws-plugin--s2member-profile-s2member-auto-eot-time" value="'.format_to_edit($auto_eot_time).'" class="regular-text" /></td>'."\n"; |
| 202 |
echo '</tr>'."\n"; |
| 203 |
|
| 204 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 205 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_after_auto_eot_time", get_defined_vars()); |
| 206 |
unset($__refs, $__v); |
| 207 |
|
| 208 |
if(c_ws_plugin__s2member_utils_conds::pro_is_installed()) |
| 209 |
{ |
| 210 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 211 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_before_reminders_enable", get_defined_vars()); |
| 212 |
unset($__refs, $__v); |
| 213 |
|
| 214 |
echo '<tr>'."\n"; |
| 215 |
echo '<th><label for="ws-plugin--s2member-profile-s2member-reminders-enable-yes">Enable Reminder Emails?</label> <a href="#" onclick="alert(\'This setting applies only if you have configured reminder email notifications in s2Member; e.g., EOT Renewal/Reminder Emails or NPT Renewal/Reminder Emails.\'); return false;" tabindex="-1">[?]</a></th>'."\n"; |
| 216 |
echo '<td><label><input type="radio" name="ws_plugin__s2member_profile_s2member_reminders_enable" id="ws-plugin--s2member-profile-s2member-reminders-enable-yes" value="1"'.((string)get_user_option('s2member_reminders_enable', $user_id) !== '0' ? ' checked' : '').' /> Yes</label> <label><input type="radio" name="ws_plugin__s2member_profile_s2member_reminders_enable" id="ws-plugin--s2member-profile-s2member-reminders-enable-no" value="0"'.((string)get_user_option('s2member_reminders_enable', $user_id) === '0' ? ' checked' : '').' /> No (exclude)</label></td>'."\n"; |
| 217 |
echo '</tr>'."\n"; |
| 218 |
|
| 219 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 220 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_after_reminders_enable", get_defined_vars()); |
| 221 |
unset($__refs, $__v); |
| 222 |
|
| 223 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 224 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_before_reset_pass_resend", get_defined_vars()); |
| 225 |
unset($__refs, $__v); |
| 226 |
|
| 227 |
echo '<tr>'."\n"; |
| 228 |
echo '<th><label for="ws-plugin--s2member-profile-reset-pass-resend">Reset Password & Resend Welcome Email Message:</label> <a href="#" onclick="alert(\'Checking this box will tell s2Member to reset this User\\\'s password and then reprocess the New User Email Notification message against this User\\\'s account. The user will get an email message with their Username and a Password reset link.\\n\\nThis can be helpful in cases where a User/Member missed the original email message for some reason. The User\\\'s password is reset to a new auto-generated password, nullifying the old one. Then, the user receives a link via email that they can use to set a new password of their choosing.\\n\\nTIP: It is possible to customize the New User Email Notification message with s2Member. Please see: `Dashboard → s2Member → General Options → Email Configuration → New User Notifications`.\'); return false;" tabindex="-1">[?]</a></th>'."\n"; |
| 229 |
echo '<td><label><input type="checkbox" name="ws_plugin__s2member_profile_reset_pass_resend" id="ws-plugin--s2member-profile-reset-pass-resend" value="1" /> Yes, reset password & resend welcome email message to this User.</label></td>'."\n"; |
| 230 |
echo '</tr>'."\n"; |
| 231 |
|
| 232 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 233 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_after_reset_pass_resend", get_defined_vars()); |
| 234 |
unset($__refs, $__v); |
| 235 |
} |
| 236 |
} |
| 237 |
if(c_ws_plugin__s2member_list_servers::list_servers_integrated()) // Only if integrated with s2Member. |
| 238 |
{ |
| 239 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 240 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_before_opt_in", get_defined_vars()); |
| 241 |
unset($__refs, $__v); |
| 242 |
|
| 243 |
echo '<tr>'."\n"; |
| 244 |
echo '<th><label for="ws-plugin--s2member-profile-opt-in">Re-process List Servers:</label> <a href="#" onclick="alert(\'You have at least one List Server integrated with s2Member. Would you like to re-process a confirmation request for this User? If not, just leave the box un-checked.\'); return false;" tabindex="-1">[?]</a></th>'."\n"; |
| 245 |
echo '<td><label><input type="checkbox" name="ws_plugin__s2member_profile_opt_in" id="ws-plugin--s2member-profile-opt-in" value="1" /> Yes, send a mailing list confirmation email to this User.</label></td>'."\n"; |
| 246 |
echo '</tr>'."\n"; |
| 247 |
|
| 248 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 249 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_after_opt_in", get_defined_vars()); |
| 250 |
unset($__refs, $__v); |
| 251 |
|
| 252 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_auto_opt_out_transitions"]) |
| 253 |
if(($custom_reg_auto_op_outs = c_ws_plugin__s2member_utils_strings::wrap_deep($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_auto_opt_outs"], "/^", "$/i"))) |
| 254 |
if(c_ws_plugin__s2member_utils_arrays::in_regex_array("user-role-change", $custom_reg_auto_op_outs) || c_ws_plugin__s2member_utils_arrays::in_regex_array("modification", $custom_reg_auto_op_outs)) |
| 255 |
{ |
| 256 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 257 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_before_auto_opt_out_transitions", get_defined_vars()); |
| 258 |
unset($__refs, $__v); |
| 259 |
|
| 260 |
echo '<tr>'."\n"; |
| 261 |
echo '<th><label for="ws-plugin--s2member-custom-reg-auto-opt-out-transitions">Allow List Transitioning:</label> <a href="#" onclick="alert(\'You\\\'ve configured s2Member with List Transitions enabled. By leaving this box checked, s2Member will Transition the User\\\'s mailing list subscription(s) automatically. For example, if a Member is demoted from Level #2, down to Level #1; s2Member will add them to the Level #1 List(s) after it removes them from the Level #2 List(s).\\n\\nDepending on your configuration of s2Member, a transition may ONLY occur if s2Member IS able to successfully remove them from an existing List. In other words, if they are currently NOT subscribed to any List(s), s2Member may NOT transition them to any new Lists (depending on your configuration).\'); return false;" tabindex="-1">[?]</a></th>'."\n"; |
| 262 |
echo '<td><label><input type="checkbox" name="ws_plugin__s2member_custom_reg_auto_opt_out_transitions" id="ws-plugin--s2member-custom-reg-auto-opt-out-transitions" value="1" checked="checked" /> Yes, automatically transition this User\'s mailing list subscription(s) when/if I change their Role.</label></td>'."\n"; |
| 263 |
echo '</tr>'."\n"; |
| 264 |
|
| 265 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 266 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_after_auto_opt_out_transitions", get_defined_vars()); |
| 267 |
unset($__refs, $__v); |
| 268 |
} |
| 269 |
} |
| 270 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 271 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_before_ip_restrictions", get_defined_vars()); |
| 272 |
unset($__refs, $__v); |
| 273 |
|
| 274 |
echo '<tr>'."\n"; |
| 275 |
echo '<th><label for="ws-plugin--s2member-profile-ip-restrictions">Reset IP Restrictions:</label> <a href="#" onclick="alert(\'A single Username is only valid for a certain number of unique IP addresses (as configured in your s2Member → General Options). Once that limit is reached, s2Member assumes there has been a security breach. At that time, s2Member will place a temporary ban (preventing access).\\n\\nIf you have spoken to a legitimate Customer that is receiving an error upon logging in (ex: 503 / too many IP addresses), you can remove this temporary ban by checking the box below. If the abusive behavior continues, s2Member will automatically re-instate IP Restrictions in the future. If you would like to gain further control over IP Restrictions, please check your General Options panel for s2Member.\'); return false;" tabindex="-1">[?]</a></th>'."\n"; |
| 276 |
echo '<td><label><input type="checkbox" name="ws_plugin__s2member_profile_ip_restrictions" id="ws-plugin--s2member-profile-ip-restrictions" value="1" /> Yes, delete/reset IP Restrictions associated with this Username.</label>'.((c_ws_plugin__s2member_ip_restrictions::specific_ip_restriction_at_or_above_max(strtolower($user->user_login)) || c_ws_plugin__s2member_ip_restrictions::specific_ip_restriction_breached_security(strtolower($user->user_login))) ? '<br /><em>*WARNING* this User is at (or above) max allowable IP addresses (based on your IP Restrictions).</em>' : '<br /><em>*Note* this User is NOT currently banned by any of your IP Restrictions.</em>').'</td>'."\n"; |
| 277 |
echo '</tr>'."\n"; |
| 278 |
|
| 279 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 280 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_after_ip_restrictions", get_defined_vars()); |
| 281 |
unset($__refs, $__v); |
| 282 |
|
| 283 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) // Only if configured. |
| 284 |
if($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level($level, "administrative")) |
| 285 |
{ |
| 286 |
echo '<tr>'."\n"; |
| 287 |
echo '<td colspan="2">'."\n"; |
| 288 |
echo '<div style="height:1px; line-height:1px; background:#CCCCCC;"></div>'."\n"; |
| 289 |
echo '</td>'."\n"; |
| 290 |
echo '</tr>'."\n"; |
| 291 |
|
| 292 |
$fields = get_user_option("s2member_custom_fields", $user_id); // Existing fields. |
| 293 |
|
| 294 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 295 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_before_custom_fields", get_defined_vars()); |
| 296 |
unset($__refs, $__v); |
| 297 |
|
| 298 |
foreach(json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], TRUE) as $field) |
| 299 |
{ |
| 300 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 301 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_during_custom_fields_before", get_defined_vars()); |
| 302 |
unset($__refs, $__v); |
| 303 |
|
| 304 |
if(in_array($field["id"], $fields_applicable)) // Field applicable? |
| 305 |
{ |
| 306 |
$field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"])); |
| 307 |
$field_id_class = preg_replace("/_/", "-", $field_var); |
| 308 |
|
| 309 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 310 |
if(apply_filters("ws_plugin__s2member_during_users_list_edit_cols_during_custom_fields_display", TRUE, get_defined_vars())) |
| 311 |
{ |
| 312 |
if(!empty($field["section"]) && $field["section"] === "yes") // Starts a new section? |
| 313 |
echo '<tr><td colspan="2"><div class="ws-plugin--s2member-profile-divider-section'.((!empty($field["sectitle"])) ? '-title' : '').'">'.((!empty($field["sectitle"])) ? $field["sectitle"] : '').'</div></td></tr>'; |
| 314 |
|
| 315 |
echo '<tr>'."\n"; |
| 316 |
echo '<th><label for="ws-plugin--s2member-profile-'.esc_attr($field_id_class).'">'.((preg_match("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ucwords(preg_replace("/_/", " ", $field_var)) : $field["label"]).':</label></th>'."\n"; |
| 317 |
echo '<td>'.c_ws_plugin__s2member_custom_reg_fields::custom_field_gen(__FUNCTION__, $field, "ws_plugin__s2member_profile_", "ws-plugin--s2member-profile-", "", ((preg_match("/^(text|textarea|select|selects)$/", $field["type"])) ? "width:99%;" : ""), "", "", $fields, @$fields[$field_var], "administrative").'</td>'."\n"; |
| 318 |
echo '</tr>'."\n"; |
| 319 |
} |
| 320 |
unset($__refs, $__v); |
| 321 |
} |
| 322 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 323 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_during_custom_fields_after", get_defined_vars()); |
| 324 |
unset($__refs, $__v); |
| 325 |
} |
| 326 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 327 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_after_custom_fields", get_defined_vars()); |
| 328 |
unset($__refs, $__v); |
| 329 |
|
| 330 |
echo '<tr>'."\n"; |
| 331 |
echo '<td colspan="2">'."\n"; |
| 332 |
echo '<div style="height:1px; line-height:1px; background:#CCCCCC;"></div>'."\n"; |
| 333 |
echo '</td>'."\n"; |
| 334 |
echo '</tr>'."\n"; |
| 335 |
} |
| 336 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 337 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_before_notes", get_defined_vars()); |
| 338 |
unset($__refs, $__v); |
| 339 |
|
| 340 |
echo '<tr>'."\n"; |
| 341 |
echo '<th><label for="ws-plugin--s2member-profile-s2member-notes">Administrative Notes:</label> <a href="#" onclick="alert(\'This is for Administrative purposes. You can keep a list of Notations about this account. These Notations are private; Users/Members will never see these.\\n\\n*Note* The s2Member software may `append` Notes to this field occasionally, under special circumstances. For example, when/if s2Member demotes a paid Member to a Free Subscriber, s2Member will leave a Note in this field.\'); return false;" tabindex="-1">[?]</a><br /><br /><small>These Notations are private; Users/Members will never see any of these notes.</small></th>'."\n"; |
| 342 |
echo '<td><textarea name="ws_plugin__s2member_profile_s2member_notes" id="ws-plugin--s2member-profile-s2member-notes" rows="5" wrap="off" spellcheck="false" style="width:99%;">'.format_to_edit(get_user_option("s2member_notes", $user_id)).'</textarea></td>'."\n"; |
| 343 |
echo '</tr>'."\n"; |
| 344 |
|
| 345 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 346 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_after_notes", get_defined_vars()); |
| 347 |
unset($__refs, $__v); |
| 348 |
|
| 349 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 350 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_after", get_defined_vars()); |
| 351 |
unset($__refs, $__v); |
| 352 |
|
| 353 |
echo '</table>'."\n"; |
| 354 |
|
| 355 |
echo '<div style="margin:25px 0 25px 0; height:1px; line-height:1px; background:#CCCCCC;"></div>'."\n"; |
| 356 |
} |
| 357 |
else if($current_user->ID === $user->ID) // Otherwise, a User can always edit their own Profile. |
| 358 |
{ |
| 359 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"] /* Only if configured. */) |
| 360 |
if($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level($level, "profile")) |
| 361 |
{ |
| 362 |
echo '<div style="margin:25px 0 25px 0; height:1px; line-height:1px; background:#CCCCCC;"></div>'."\n"; |
| 363 |
|
| 364 |
echo '<h3>'._x("Additional Profile Fields", "s2member-front", "s2member").((is_multisite()) ? ' '._x("(for this site)", "s2member-front", "s2member") : "").'</h3>'."\n"; |
| 365 |
|
| 366 |
echo '<table class="form-table">'."\n"; |
| 367 |
|
| 368 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 369 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_before", get_defined_vars()); |
| 370 |
unset($__refs, $__v); |
| 371 |
|
| 372 |
$fields = get_user_option("s2member_custom_fields", $user_id); // Existing fields. |
| 373 |
|
| 374 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 375 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_before_custom_fields", get_defined_vars()); |
| 376 |
unset($__refs, $__v); |
| 377 |
|
| 378 |
foreach(json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], TRUE) as $field) |
| 379 |
{ |
| 380 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 381 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_during_custom_fields_before", get_defined_vars()); |
| 382 |
unset($__refs, $__v); |
| 383 |
|
| 384 |
if(in_array($field["id"], $fields_applicable)) // Field applicable? |
| 385 |
{ |
| 386 |
$field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"])); |
| 387 |
$field_id_class = preg_replace("/_/", "-", $field_var); |
| 388 |
|
| 389 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 390 |
if(apply_filters("ws_plugin__s2member_during_users_list_edit_cols_during_custom_fields_display", TRUE, get_defined_vars())) |
| 391 |
{ |
| 392 |
if(!empty($field["section"]) && $field["section"] === "yes") // Starts a new section? |
| 393 |
echo '<tr><td colspan="2"><div class="ws-plugin--s2member-profile-divider-section'.((!empty($field["sectitle"])) ? '-title' : '').'">'.((!empty($field["sectitle"])) ? $field["sectitle"] : '').'</div></td></tr>'; |
| 394 |
|
| 395 |
echo '<tr>'."\n"; |
| 396 |
echo '<th><label for="ws-plugin--s2member-profile-'.esc_attr($field_id_class).'">'.((preg_match("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ucwords(preg_replace("/_/", " ", $field_var)) : $field["label"]).':</label></th>'."\n"; |
| 397 |
echo '<td>'.c_ws_plugin__s2member_custom_reg_fields::custom_field_gen(__FUNCTION__, $field, "ws_plugin__s2member_profile_", "ws-plugin--s2member-profile-", "", ((preg_match("/^(text|textarea|select|selects)$/", $field["type"])) ? "width:99%;" : ""), "", "", $fields, $fields[$field_var], "profile").'</td>'."\n"; |
| 398 |
echo '</tr>'."\n"; |
| 399 |
} |
| 400 |
unset($__refs, $__v); |
| 401 |
} |
| 402 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 403 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_during_custom_fields_after", get_defined_vars()); |
| 404 |
unset($__refs, $__v); |
| 405 |
} |
| 406 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 407 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_after_custom_fields", get_defined_vars()); |
| 408 |
unset($__refs, $__v); |
| 409 |
|
| 410 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 411 |
do_action("ws_plugin__s2member_during_users_list_edit_cols_after", get_defined_vars()); |
| 412 |
unset($__refs, $__v); |
| 413 |
|
| 414 |
echo '</table>'."\n"; |
| 415 |
|
| 416 |
echo '<div style="margin:25px 0 25px 0; height:1px; line-height:1px; background:#CCCCCC;"></div>'."\n"; |
| 417 |
} |
| 418 |
} |
| 419 |
} |
| 420 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 421 |
do_action("ws_plugin__s2member_after_users_list_edit_cols", get_defined_vars()); |
| 422 |
unset($__refs, $__v); |
| 423 |
} |
| 424 |
|
| 425 |
/** |
| 426 |
* Saves Custom Fields after an admin updates Profile. |
| 427 |
* |
| 428 |
* @package s2Member\Users_List |
| 429 |
* @since 3.5 |
| 430 |
* |
| 431 |
* @attaches-to ``add_action("edit_user_profile_update");`` |
| 432 |
* @attaches-to ``add_action("personal_options_update");`` |
| 433 |
* |
| 434 |
* @param int|string $user_id Expects a numeric WordPress User ID passed in by the Action Hook. |
| 435 |
*/ |
| 436 |
public static function users_list_update_cols($user_id = '') |
| 437 |
{ |
| 438 |
global $current_site, $current_blog; // Multisite networks. |
| 439 |
|
| 440 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 441 |
do_action("ws_plugin__s2member_before_users_list_update_cols", get_defined_vars()); |
| 442 |
unset($__refs, $__v); |
| 443 |
|
| 444 |
$user = new WP_User($user_id); // We need both of these objects. `$user` and `$current_user`. |
| 445 |
$current_user = (is_user_logged_in()) ? wp_get_current_user() : FALSE; // Current user. |
| 446 |
|
| 447 |
if(is_object($user) && !empty($user->ID) && ($user_id = $user->ID) && is_object($current_user) && !empty($current_user->ID)) |
| 448 |
{ |
| 449 |
if(current_user_can("edit_users") && (!is_multisite() || is_super_admin() || is_user_member_of_blog($user_id))) |
| 450 |
{ |
| 451 |
if(!empty($_POST) && is_array($_p = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST)))) |
| 452 |
{ |
| 453 |
$old_user = unserialize(serialize($user)); // Copy existing User obj. |
| 454 |
$old_role = c_ws_plugin__s2member_user_access::user_access_role($old_user); |
| 455 |
|
| 456 |
$role = isset($_p["role"]) && $_p["role"] !== $old_role ? $_p["role"] : $old_role; |
| 457 |
$level = c_ws_plugin__s2member_user_access::user_access_role_to_level($role); |
| 458 |
|
| 459 |
$user->roles = isset($_p["role"]) && $_p["role"] !== $old_role ? array($_p["role"]) : $old_user->roles; |
| 460 |
$user->user_email = isset($_p["email"]) && is_email($_p["email"]) && $_p["email"] !== $old_user->user_email && !email_exists($_p["email"]) ? $_p["email"] : $old_user->user_email; |
| 461 |
$user->first_name = isset($_p["first_name"]) && $_p["first_name"] !== $old_user->first_name ? $_p["first_name"] : $old_user->first_name; |
| 462 |
$user->last_name = isset($_p["last_name"]) && $_p["last_name"] !== $old_user->last_name ? $_p["last_name"] : $old_user->last_name; |
| 463 |
|
| 464 |
$auto_eot_time = !empty($_p["ws_plugin__s2member_profile_s2member_auto_eot_time"]) ? strtotime($_p["ws_plugin__s2member_profile_s2member_auto_eot_time"]) : ""; |
| 465 |
|
| 466 |
if($role !== $old_role) // In this case, we need to fire Hook: `ws_plugin__s2member_during_collective_mods`. |
| 467 |
do_action("ws_plugin__s2member_during_collective_mods", $user_id, get_defined_vars(), "user-role-change", "modification", $role, $user, $old_user); |
| 468 |
|
| 469 |
if(isset($_p["ws_plugin__s2member_profile_s2member_originating_blog"]) && is_multisite() && is_super_admin()) |
| 470 |
update_user_meta($user_id, "s2member_originating_blog", $_p["ws_plugin__s2member_profile_s2member_originating_blog"]); |
| 471 |
|
| 472 |
if(isset($_p["ws_plugin__s2member_profile_s2member_subscr_gateway"])) |
| 473 |
update_user_option($user_id, "s2member_subscr_gateway", $_p["ws_plugin__s2member_profile_s2member_subscr_gateway"]); |
| 474 |
|
| 475 |
if(isset($_p["ws_plugin__s2member_profile_s2member_subscr_id"])) |
| 476 |
update_user_option($user_id, "s2member_subscr_id", $_p["ws_plugin__s2member_profile_s2member_subscr_id"]); |
| 477 |
|
| 478 |
if(isset($_p["ws_plugin__s2member_profile_s2member_subscr_cid"])) |
| 479 |
update_user_option($user_id, "s2member_subscr_cid", $_p["ws_plugin__s2member_profile_s2member_subscr_cid"]); |
| 480 |
|
| 481 |
if(isset($_p["ws_plugin__s2member_profile_s2member_custom"])) |
| 482 |
update_user_option($user_id, "s2member_custom", $_p["ws_plugin__s2member_profile_s2member_custom"]); |
| 483 |
|
| 484 |
if(isset($_p["ws_plugin__s2member_profile_s2member_coupon_codes"])) |
| 485 |
update_user_option($user_id, "s2member_coupon_codes", array_map('trim', preg_split('/,+/', $_p["ws_plugin__s2member_profile_s2member_coupon_codes"], -1, PREG_SPLIT_NO_EMPTY))); |
| 486 |
|
| 487 |
if(isset($_p["ws_plugin__s2member_profile_s2member_registration_ip"])) |
| 488 |
update_user_option($user_id, "s2member_registration_ip", $_p["ws_plugin__s2member_profile_s2member_registration_ip"]); |
| 489 |
|
| 490 |
if(isset($_p["ws_plugin__s2member_profile_s2member_notes"])) |
| 491 |
update_user_option($user_id, "s2member_notes", $_p["ws_plugin__s2member_profile_s2member_notes"]); |
| 492 |
|
| 493 |
if(isset($_p["ws_plugin__s2member_profile_s2member_auto_eot_time"]) && isset($auto_eot_time)) |
| 494 |
update_user_option($user_id, "s2member_auto_eot_time", $auto_eot_time); |
| 495 |
|
| 496 |
if(isset($_p["ws_plugin__s2member_profile_s2member_reminders_enable"])) |
| 497 |
update_user_option($user_id, "s2member_reminders_enable", (string)(int)$_p["ws_plugin__s2member_profile_s2member_reminders_enable"]); |
| 498 |
|
| 499 |
if(isset($_p["ws_plugin__s2member_profile_s2member_ccaps"])) |
| 500 |
{ |
| 501 |
foreach($user->allcaps as $cap => $cap_enabled) |
| 502 |
if(preg_match("/^access_s2member_ccap_/", $cap)) |
| 503 |
$user->remove_cap($ccap = $cap); |
| 504 |
|
| 505 |
if(!empty($_p["ws_plugin__s2member_profile_s2member_ccaps"])) |
| 506 |
foreach(preg_split("/[\r\n\t\s;,]+/", $_p["ws_plugin__s2member_profile_s2member_ccaps"]) as $ccap) |
| 507 |
if(strlen($ccap = trim(strtolower(preg_replace("/[^a-z_0-9]/i", "", $ccap))))) |
| 508 |
$user->add_cap("access_s2member_ccap_".$ccap); |
| 509 |
} |
| 510 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) |
| 511 |
{ |
| 512 |
foreach(json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], TRUE) as $field) |
| 513 |
{ |
| 514 |
$field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"])); |
| 515 |
$field_id_class = preg_replace("/_/", "-", $field_var); |
| 516 |
|
| 517 |
if(isset($_p["ws_plugin__s2member_profile_".$field_var]) /* Field being set? */) |
| 518 |
{ |
| 519 |
if((is_array($_p["ws_plugin__s2member_profile_".$field_var]) && !empty($_p["ws_plugin__s2member_profile_".$field_var])) || (is_string($_p["ws_plugin__s2member_profile_".$field_var]) && strlen($_p["ws_plugin__s2member_profile_".$field_var]))) |
| 520 |
$fields[$field_var] = $_p["ws_plugin__s2member_profile_".$field_var]; |
| 521 |
else if(isset($fields)) unset($fields[$field_var]); |
| 522 |
} |
| 523 |
else if(isset($fields)) unset($fields[$field_var]); |
| 524 |
} |
| 525 |
} |
| 526 |
if(!empty($fields)) |
| 527 |
update_user_option($user_id, "s2member_custom_fields", $fields); |
| 528 |
else delete_user_option($user_id, "s2member_custom_fields"); |
| 529 |
|
| 530 |
if($level > 0 /* We only process this if they are higher than Level #0. */) |
| 531 |
{ |
| 532 |
$pr_times = (array) get_user_option("s2member_paid_registration_times", $user_id); |
| 533 |
$pr_times["level"] = (empty($pr_times["level"])) ? time() : $pr_times["level"]; |
| 534 |
$pr_times["level".$level] = (empty($pr_times["level".$level])) ? time() : $pr_times["level".$level]; |
| 535 |
update_user_option($user_id, "s2member_paid_registration_times", $pr_times); // Update now. |
| 536 |
} |
| 537 |
if(!empty($_p["ws_plugin__s2member_profile_opt_in"]) && !empty($role) && $level >= 0 /* Should we process List Servers? */) |
| 538 |
c_ws_plugin__s2member_list_servers::process_list_servers($role, $level, $user->user_login, ((!empty($_p["pass1"])) ? $_p["pass1"] : ""), $user->user_email, $user->first_name, $user->last_name, FALSE, TRUE, TRUE, $user_id); |
| 539 |
|
| 540 |
if(!empty($_p["ws_plugin__s2member_profile_ip_restrictions"]) /* Delete/reset IP Restrictions? */) |
| 541 |
c_ws_plugin__s2member_ip_restrictions::delete_reset_specific_ip_restrictions(strtolower($user->user_login)); |
| 542 |
|
| 543 |
if(!empty($_p["ws_plugin__s2member_profile_reset_pass_resend"]) && c_ws_plugin__s2member_utils_conds::pro_is_installed() /* Reset password & resend email notification? */) |
| 544 |
c_ws_plugin__s2member_email_configs::reset_pass_resend_new_user_notification($user_id, ((!empty($_p["pass1"])) ? $_p["pass1"] : ""), array("user"), $user->user_email); |
| 545 |
|
| 546 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 547 |
do_action("ws_plugin__s2member_during_users_list_update_cols", get_defined_vars()); |
| 548 |
unset($__refs, $__v); |
| 549 |
} |
| 550 |
} |
| 551 |
else if($current_user->ID === $user->ID /* Otherwise, a User can always edit their own Profile. */) |
| 552 |
{ |
| 553 |
if(!empty($_POST) && is_array($_p = c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST)))) |
| 554 |
{ |
| 555 |
$role = c_ws_plugin__s2member_user_access::user_access_role($user /* Role is not changing here. */); |
| 556 |
$level = c_ws_plugin__s2member_user_access::user_access_role_to_level($role); |
| 557 |
|
| 558 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) |
| 559 |
if($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level($level, "profile")) |
| 560 |
{ |
| 561 |
$fields = array(); // Initialize. |
| 562 |
$_existing_fields = get_user_option("s2member_custom_fields", $user_id); |
| 563 |
|
| 564 |
foreach(json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], TRUE) as $field) |
| 565 |
{ |
| 566 |
$field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"])); |
| 567 |
$field_id_class = preg_replace("/_/", "-", $field_var); |
| 568 |
|
| 569 |
if(!in_array($field["id"], $fields_applicable) || strpos($field["editable"], "no") === 0) |
| 570 |
{ |
| 571 |
if(isset($_existing_fields[$field_var]) && ((is_array($_existing_fields[$field_var]) && !empty($_existing_fields[$field_var])) || (is_string($_existing_fields[$field_var]) && strlen($_existing_fields[$field_var])))) |
| 572 |
$fields[$field_var] = $_existing_fields[$field_var]; |
| 573 |
else unset($fields[$field_var]); |
| 574 |
} |
| 575 |
else if($field["required"] === "yes" && (!isset($_p["ws_plugin__s2member_profile_".$field_var]) || (!is_array($_p["ws_plugin__s2member_profile_".$field_var]) && !is_string($_p["ws_plugin__s2member_profile_".$field_var])) || (is_array($_p["ws_plugin__s2member_profile_".$field_var]) && empty($_p["ws_plugin__s2member_profile_".$field_var])) || (is_string($_p["ws_plugin__s2member_profile_".$field_var]) && !strlen($_p["ws_plugin__s2member_profile_".$field_var])))) |
| 576 |
{ |
| 577 |
if(isset($_existing_fields[$field_var]) && ((is_array($_existing_fields[$field_var]) && !empty($_existing_fields[$field_var])) || (is_string($_existing_fields[$field_var]) && strlen($_existing_fields[$field_var])))) |
| 578 |
$fields[$field_var] = $_existing_fields[$field_var]; |
| 579 |
else unset($fields[$field_var]); |
| 580 |
} |
| 581 |
else if(isset($_p["ws_plugin__s2member_profile_".$field_var])) |
| 582 |
{ |
| 583 |
if((is_array($_p["ws_plugin__s2member_profile_".$field_var]) && !empty($_p["ws_plugin__s2member_profile_".$field_var])) || (is_string($_p["ws_plugin__s2member_profile_".$field_var]) && strlen($_p["ws_plugin__s2member_profile_".$field_var]))) |
| 584 |
$fields[$field_var] = $_p["ws_plugin__s2member_profile_".$field_var]; |
| 585 |
else unset($fields[$field_var]); |
| 586 |
} |
| 587 |
else unset($fields[$field_var]); |
| 588 |
} |
| 589 |
if(!empty($fields)) |
| 590 |
update_user_option($user_id, "s2member_custom_fields", $fields); |
| 591 |
else delete_user_option($user_id, "s2member_custom_fields"); |
| 592 |
} |
| 593 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 594 |
do_action("ws_plugin__s2member_during_users_list_update_cols", get_defined_vars()); |
| 595 |
unset($__refs, $__v); |
| 596 |
} |
| 597 |
} |
| 598 |
} |
| 599 |
foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 600 |
do_action("ws_plugin__s2member_after_users_list_update_cols", get_defined_vars()); |
| 601 |
unset($__refs, $__v); |
| 602 |
} |
| 603 |
} |
| 604 |
} |
| 605 |
|