s2Member Framework (Member Roles, Capabilities, Membership, PayPal Members) - Version 2.9.4

Version Description

  • Bug fix in %%current_user_login%% for Special Redirection URLs. Was not processing correctly. This has been resolved in 2.9.4+.
  • Bug fix in AWeber/MailChimp integration for Free Subscriber registrations. Specifically, those originating from the front-end.
  • Extra security hardening. MCRYPT_RIJNDAEL_256 / CBC now being utilized in Registration Access Cookies.
  • New feature. s2Member now supports a custom Double Opt-In Checkbox for its List Server integrations. See s2Member -> API List Servers -> Double Opt-In. This is also compatible with BuddyPress registration forms.
Download this release

Release Info

Developer PriMoThemes
Plugin Icon 128x128 s2Member Framework (Member Roles, Capabilities, Membership, PayPal Members)
Version 2.9.4
Comparing to
See all releases

Code changes from version 2.9.3 to 2.9.4

images/checked.png ADDED
Binary file
images/unchecked.png ADDED
Binary file
includes/functions/list-servers.inc.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Copyright: © 2009 WebSharks, Inc. ( coded in the USA )
4
+ <mailto:support@websharks-inc.com> <http://www.websharks-inc.com/>
5
+
6
+ Released under the terms of the GNU General Public License.
7
+ You should have received a copy of the GNU General Public License,
8
+ along with this software. In the main directory, see: /licensing/
9
+ If not, see: <http://www.gnu.org/licenses/>.
10
+ */
11
+ /*
12
+ Direct access denial.
13
+ */
14
+ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
15
+ exit;
16
+ /*
17
+ Function that process list server integrations for s2Member.
18
+ */
19
+ function ws_plugin__s2member_process_list_servers ($level = FALSE, $email = FALSE, $fname = FALSE, $lname = FALSE, $ip = FALSE, $opt_in = FALSE)
20
+ {
21
+ if (strlen ($level) && is_email ($email) && $opt_in) /* Must have a level, a valid email, and opt-in permission. */
22
+ {
23
+ if (($mailchimp_api_key = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]))
24
+ if (($mailchimp_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]))
25
+ {
26
+ if (!class_exists ("NC_MCAPI"))
27
+ include_once dirname (dirname (__FILE__)) . "/mailchimp/nc-mcapi.inc.php";
28
+ /**/
29
+ $MCAPI = new NC_MCAPI ($mailchimp_api_key); /* MailChimp® API class. */
30
+ /**/
31
+ foreach (preg_split ("/[\r\n\t\s;,]+/", $mailchimp_list_ids) as $mailchimp_list_id)
32
+ $MCAPI->listSubscribe ($mailchimp_list_id, $email, array ("FNAME" => $fname, "LNAME" => $lname, "OPTINIP" => $ip));
33
+ }
34
+ /**/
35
+ if ($aweber_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"])
36
+ {
37
+ foreach (preg_split ("/[\r\n\t\s;,]+/", $aweber_list_ids) as $aweber_list_id)
38
+ @mail ($aweber_list_id . "@aweber.com", "s2Member Subscription Request",/**/
39
+ "s2Member Subscription Request\ns2Member w/ PayPal Email ID\nBuyer: " . $fname . " " . $lname . "\n - end.",/**/
40
+ "From: \"" . preg_replace ("/\"/", "", $fname . " " . $lname) . "\" <" . $email . ">\r\nContent-Type: text/plain; charset=utf-8");
41
+ }
42
+ }
43
+ /**/
44
+ return;
45
+ }
46
+ /*
47
+ Function that determines whether or not any list
48
+ servers have been integrated into the s2Member options.
49
+ */
50
+ function ws_plugin__s2member_list_servers_integrated ()
51
+ {
52
+ for ($i = 0; $i <= 4; $i++)
53
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_mailchimp_list_ids"]/**/
54
+ || $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $i . "_aweber_list_ids"])
55
+ return true;
56
+ /**/
57
+ return false;
58
+ }
59
+ ?>
includes/functions/login-redirection.inc.php CHANGED
@@ -29,7 +29,7 @@ function ws_plugin__s2member_login_redirect ($username = FALSE)
29
  /**/
30
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"])
31
  wp_redirect (ws_plugin__s2member_fill_login_redirect_rc_vars /* Special. */
32
- ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"]));
33
  /**/
34
  else /* Otherwise, use the Login Welcome Page for s2Member. */
35
  wp_redirect (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
29
  /**/
30
  if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"])
31
  wp_redirect (ws_plugin__s2member_fill_login_redirect_rc_vars /* Special. */
32
+ ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_redirection_override"], $user));
33
  /**/
34
  else /* Otherwise, use the Login Welcome Page for s2Member. */
35
  wp_redirect (get_page_link ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["login_welcome_page"]));
includes/functions/paypal-return.inc.php CHANGED
@@ -201,9 +201,9 @@ function ws_plugin__s2member_paypal_return ()
201
  /**/
202
  $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup|subscr_payment) w/o update vars.";
203
  /**/
204
- setcookie ("s2member_subscr_id", $paypal["subscr_id"], time () + 31556926, "/");
205
- setcookie ("s2member_custom", $paypal["custom"], time () + 31556926, "/");
206
- setcookie ("s2member_level", $paypal["item_number"], time () + 31556926, "/");
207
  /**/
208
  $paypal["s2member_log"][] = "s2Member cookies set on (web_accept|subscr_signup|subscr_payment) w/o update vars.";
209
  /**/
201
  /**/
202
  $paypal["s2member_log"][] = "s2Member txn_type identified as (web_accept|subscr_signup|subscr_payment) w/o update vars.";
203
  /**/
204
+ setcookie ("s2member_subscr_id", ws_plugin__s2member_encrypt ($paypal["subscr_id"]), time () + 31556926, "/");
205
+ setcookie ("s2member_custom", ws_plugin__s2member_encrypt ($paypal["custom"]), time () + 31556926, "/");
206
+ setcookie ("s2member_level", ws_plugin__s2member_encrypt ($paypal["item_number"]), time () + 31556926, "/");
207
  /**/
208
  $paypal["s2member_log"][] = "s2Member cookies set on (web_accept|subscr_signup|subscr_payment) w/o update vars.";
209
  /**/
includes/functions/register-access.inc.php CHANGED
@@ -37,11 +37,11 @@ function ws_plugin__s2member_check_register_access ($users_can_register = FALSE)
37
  {
38
  return apply_filters ("s2member_check_register_access", ($users_can_register = "1"));
39
  }
40
- else if ($pagenow !== "options-general.php" && $_COOKIE["s2member_subscr_id"] && $_COOKIE["s2member_custom"] && preg_match ("/^[1-4](\:|$)/", $_COOKIE["s2member_level"]))
41
  {
42
  global $wpdb; /* Global database object reference. */
43
  /**/
44
- if (!$usermeta = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = 's2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($_COOKIE["s2member_subscr_id"]) . "' LIMIT 1"))
45
  {
46
  return apply_filters ("s2member_check_register_access", ($users_can_register = "1"));
47
  }
@@ -91,7 +91,7 @@ function ws_plugin__s2member_custom_registration_fields ()
91
  echo '<p>' . "\n";
92
  echo '<label>' . "\n";
93
  echo 'Password *' . "\n";
94
- echo '<input aria-required="true" type="password" maxlength="100" name="ws_plugin__s2member_custom_reg_field_user_pass" id="ws-plugin--s2member-custom-reg-field-user-pass" class="ws-plugin--s2member-custom-reg-field input" size="25" tabindex="' . esc_attr (($tabindex = $tabindex + 1)) . '" value="' . format_to_edit (trim (stripslashes ($_REQUEST["ws_plugin__s2member_custom_reg_field_user_pass"]))) . '" />' . "\n";
95
  echo '</label>' . "\n";
96
  echo '</p>';
97
  }
@@ -99,14 +99,14 @@ function ws_plugin__s2member_custom_registration_fields ()
99
  echo '<p>' . "\n";
100
  echo '<label>' . "\n";
101
  echo 'First Name *' . "\n";
102
- echo '<input aria-required="true" type="text" maxlength="100" name="ws_plugin__s2member_custom_reg_field_first_name" id="ws-plugin--s2member-custom-reg-field-first-name" class="ws-plugin--s2member-custom-reg-field input" size="25" tabindex="' . esc_attr (($tabindex = $tabindex + 1)) . '" value="' . format_to_edit (trim (stripslashes ($_REQUEST["ws_plugin__s2member_custom_reg_field_first_name"]))) . '" />' . "\n";
103
  echo '</label>' . "\n";
104
  echo '</p>';
105
  /**/
106
  echo '<p>' . "\n";
107
  echo '<label>' . "\n";
108
  echo 'Last Name *' . "\n";
109
- echo '<input aria-required="true" type="text" maxlength="100" name="ws_plugin__s2member_custom_reg_field_last_name" id="ws-plugin--s2member-custom-reg-field-last-name" class="ws-plugin--s2member-custom-reg-field input" size="25" tabindex="' . esc_attr (($tabindex = $tabindex + 1)) . '" value="' . format_to_edit (trim (stripslashes ($_REQUEST["ws_plugin__s2member_custom_reg_field_last_name"]))) . '" />' . "\n";
110
  echo '</label>' . "\n";
111
  echo '</p>';
112
  /**/
@@ -121,12 +121,22 @@ function ws_plugin__s2member_custom_registration_fields ()
121
  echo '<label>' . "\n";
122
  echo esc_html ($field) . (($req) ? " *" : "") . "\n";
123
  $field = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field));
124
- echo '<input' . $req . ' type="text" maxlength="100" name="ws_plugin__s2member_custom_reg_field_' . esc_attr ($field) . '" id="ws-plugin--s2member-custom-reg-field-' . esc_attr (preg_replace ("/_/", "-", $field)) . '" class="ws-plugin--s2member-custom-reg-field input" size="25" tabindex="' . esc_attr (($tabindex = $tabindex + 1)) . '" value="' . format_to_edit (trim (stripslashes ($_REQUEST["ws_plugin__s2member_custom_reg_field_" . $field]))) . '" />' . "\n";
125
  echo '</label>' . "\n";
126
  echo '</p>';
127
  }
128
  }
129
  /**/
 
 
 
 
 
 
 
 
 
 
130
  do_action ("s2member_during_custom_registration_fields");
131
  }
132
  /**/
@@ -135,6 +145,34 @@ function ws_plugin__s2member_custom_registration_fields ()
135
  return;
136
  }
137
  /*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  Generates registration links.
139
  */
140
  function ws_plugin__s2member_register_link_gen ($subscr_id = FALSE, $custom = FALSE, $item_number = FALSE, $shrink = TRUE)
@@ -157,21 +195,20 @@ function ws_plugin__s2member_register_link_gen ($subscr_id = FALSE, $custom = FA
157
  /*
158
  Handles registration links.
159
  Attach to: add_action("init");
160
- $_GET["s2member_paypal_register"] deprecated in v2.8.6.
161
  */
162
  function ws_plugin__s2member_register ()
163
  {
164
  do_action ("s2member_before_register");
165
  /**/
166
- if ($_GET["s2member_register"] || ($_GET["s2member_register"] = $_GET["s2member_paypal_register"]))
167
  {
168
  if (is_array ($register = preg_split ("/\:\.\:\|\:\.\:/", ws_plugin__s2member_decrypt ($_GET["s2member_register"]))))
169
  {
170
  if (count ($register) === 4 && $register[0] === "subscr_id_custom_item_number" && $register[1] && $register[2] && $register[3])
171
  {
172
- setcookie ("s2member_subscr_id", $register[1], time () + 31556926, "/");
173
- setcookie ("s2member_custom", $register[2], time () + 31556926, "/");
174
- setcookie ("s2member_level", $register[3], time () + 31556926, "/");
175
  /**/
176
  do_action ("s2member_during_register");
177
  /**/
@@ -188,12 +225,11 @@ function ws_plugin__s2member_register ()
188
  /*
189
  Function for configuring new users.
190
  Attach to: add_action("user_register");
191
- Attach to: add_action("bp_core_signup_user");
192
  */
193
  function ws_plugin__s2member_configure_user_registration ($user_id = FALSE)
194
  {
195
  global $wpdb; /* Global database object may be required for this routine. */
196
- static $processed; /* Prevents duplicate processing when attached to multiple hooks in support of plugins like BuddyPress. */
197
  /**/
198
  do_action ("s2member_before_configure_user_registration");
199
  /**/
@@ -201,177 +237,102 @@ function ws_plugin__s2member_configure_user_registration ($user_id = FALSE)
201
  {
202
  ws_plugin__s2member_email_config (); /* Configures From: header that will be used in new user notifications. */
203
  /**/
204
- if (!is_admin () /* Only run this particular routine whenever a Member is registering themselves. */
205
- && $_COOKIE["s2member_subscr_id"] && $_COOKIE["s2member_custom"] && preg_match ("/^[1-4](\:|$)/", $_COOKIE["s2member_level"]))
 
 
206
  {
207
- list ($level, $ccaps) = preg_split ("/\:/", $_COOKIE["s2member_level"], 2); /* Supports colon separated level:custom_capability,custom_capability. */
208
  /**/
209
- if (!$usermeta = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = 's2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($_COOKIE["s2member_subscr_id"]) . "' LIMIT 1"))
210
- {
211
- $user->set_role ("s2member_level" . $level);
212
- /**/
213
- if ($ccaps) /* Add custom capabilities. */
214
- foreach (preg_split ("/[\r\n\t\s;,]+/", $ccaps) as $ccap)
215
- if (strlen ($ccap)) /* Don't add empty capabilities. */
216
- $user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
217
- /**/
218
- update_usermeta ($user_id, "s2member_subscr_id", $_COOKIE["s2member_subscr_id"]);
219
- update_usermeta ($user_id, "s2member_custom", $_COOKIE["s2member_custom"]);
220
- /**/
221
- if (($mailchimp_api_key = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]) && ($mailchimp_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]))
222
- {
223
- if (!class_exists ("NC_MCAPI"))
224
- include_once dirname (dirname (__FILE__)) . "/mailchimp/nc-mcapi.inc.php";
225
- /**/
226
- $MCAPI = new NC_MCAPI ($mailchimp_api_key); /* MailChimp® API class. */
227
- /**/
228
- $email = $user->user_email;
229
- $login = $user->user_login;
230
- $fname = ($user->first_name) ? $user->first_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]);
231
- $lname = ($user->last_name) ? $user->last_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]);
232
- /**/
233
- foreach (preg_split ("/[\r\n\t\s;,]+/", $mailchimp_list_ids) as $mailchimp_list_id)
234
- $MCAPI->listSubscribe ($mailchimp_list_id, $email, array ("FNAME" => $fname, "LNAME" => $lname, "OPTINIP" => $_SERVER["REMOTE_ADDR"]));
235
- }
236
- /**/
237
- if ($aweber_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"])
238
- {
239
- $email = $user->user_email;
240
- $login = $user->user_login;
241
- $fname = ($user->first_name) ? $user->first_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]);
242
- $lname = ($user->last_name) ? $user->last_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]);
243
- /**/
244
- foreach (preg_split ("/[\r\n\t\s;,]+/", $aweber_list_ids) as $aweber_list_id)
245
- @mail ($aweber_list_id . "@aweber.com", "s2Member Subscription Request",/**/
246
- "s2Member Subscription Request\ns2Member w/ PayPal Email ID\nBuyer: " . $fname . " " . $lname . "\n - end.",/**/
247
- "From: \"" . preg_replace ("/\"/", "", $fname . " " . $lname) . "\" <" . $email . ">\r\nContent-Type: text/plain; charset=utf-8");
248
- }
249
- /**/
250
- if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_urls"])
251
- {
252
- $email = $user->user_email;
253
- $login = $user->user_login;
254
- $fname = ($user->first_name) ? $user->first_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]);
255
- $lname = ($user->last_name) ? $user->last_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]);
256
- /**/
257
- if (function_exists ("ws_plugin__s2member_generate_password"))
258
- if (!defined ("BP_VERSION") && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
259
- if (wp_verify_nonce (trim (stripslashes ($_POST["ws_plugin__s2member_registration"])), "ws-plugin--s2member-registration"))
260
- if ($pass = trim (stripslashes ($_POST["ws_plugin__s2member_custom_reg_field_user_pass"])))
261
- $pass = $pass;
262
- /**/
263
- if (is_array ($cv = preg_split ("/\|/", $_COOKIE["s2member_custom"])))
264
- foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_urls"]) as $url)
265
- if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)))
266
- if (($url = preg_replace ("/%%level%%/i", urlencode ($level), $url)))
267
- if (($url = preg_replace ("/%%user_first_name%%/i", urlencode ($fname), $url)))
268
- if (($url = preg_replace ("/%%user_last_name%%/i", urlencode ($lname), $url)))
269
- if (($url = preg_replace ("/%%user_full_name%%/i", urlencode (trim ($fname . " " . $lname)), $url)))
270
- if (($url = preg_replace ("/%%user_email%%/i", urlencode ($email), $url)))
271
- if (($url = preg_replace ("/%%user_login%%/i", urlencode ($login), $url)))
272
- if (($url = preg_replace ("/%%user_pass%%/i", urlencode ($pass), $url)))
273
- if (($url = trim ($url))) /* Make sure it is not empty. */
274
- ws_plugin__s2member_curlpsr ($url, "s2member=1");
275
- }
276
- /**/
277
- do_action ("s2member_during_configure_user_registration_front_side");
278
- }
279
  /**/
280
- setcookie ("s2member_subscr_id", "", time () + 31556926, "/");
281
- setcookie ("s2member_custom", "", time () + 31556926, "/");
282
- setcookie ("s2member_level", "", time () + 31556926, "/");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  }
284
  /**/
285
  else if (is_admin () && preg_match ("/wp-admin\/user-new\.php/", $_POST["_wp_http_referer"]) && preg_match ("/^(subscriber|s2member_level[1-4])$/", $_POST["role"]))
286
  {
287
- if ($_POST["role"] === "subscriber" && ($mailchimp_api_key = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]) && ($mailchimp_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_mailchimp_list_ids"]))
288
- {
289
- if (!class_exists ("NC_MCAPI"))
290
- include_once dirname (dirname (__FILE__)) . "/mailchimp/nc-mcapi.inc.php";
291
- /**/
292
- $MCAPI = new NC_MCAPI ($mailchimp_api_key); /* MailChimp® API class. */
293
- /**/
294
- $email = $user->user_email;
295
- $login = $user->user_login;
296
- $fname = ($user->first_name) ? $user->first_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]);
297
- $lname = ($user->last_name) ? $user->last_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]);
298
- /**/
299
- foreach (preg_split ("/[\r\n\t\s;,]+/", $mailchimp_list_ids) as $mailchimp_list_id)
300
- $MCAPI->listSubscribe ($mailchimp_list_id, $email, array ("FNAME" => $fname, "LNAME" => $lname, "OPTINIP" => ""));
301
- }
302
  /**/
303
- else if (($level = preg_replace ("/[^1-4]/", "", $_POST["role"])) && ($mailchimp_api_key = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]) && ($mailchimp_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_mailchimp_list_ids"]))
304
- {
305
- if (!class_exists ("NC_MCAPI"))
306
- include_once dirname (dirname (__FILE__)) . "/mailchimp/nc-mcapi.inc.php";
307
- /**/
308
- $MCAPI = new NC_MCAPI ($mailchimp_api_key); /* MailChimp® API class. */
309
- /**/
310
- $email = $user->user_email;
311
- $login = $user->user_login;
312
- $fname = ($user->first_name) ? $user->first_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]);
313
- $lname = ($user->last_name) ? $user->last_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]);
314
- /**/
315
- foreach (preg_split ("/[\r\n\t\s;,]+/", $mailchimp_list_ids) as $mailchimp_list_id)
316
- $MCAPI->listSubscribe ($mailchimp_list_id, $email, array ("FNAME" => $fname, "LNAME" => $lname, "OPTINIP" => ""));
317
- }
318
  /**/
319
- if ($_POST["role"] === "subscriber" && ($aweber_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level0_aweber_list_ids"]))
320
- {
321
- $email = $user->user_email;
322
- $login = $user->user_login;
323
- $fname = ($user->first_name) ? $user->first_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]);
324
- $lname = ($user->last_name) ? $user->last_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]);
325
- /**/
326
- foreach (preg_split ("/[\r\n\t\s;,]+/", $aweber_list_ids) as $aweber_list_id)
327
- @mail ($aweber_list_id . "@aweber.com", "s2Member Subscription Request",/**/
328
- "s2Member Subscription Request\ns2Member w/ PayPal Email ID\nBuyer: " . $fname . " " . $lname . "\n - end.",/**/
329
- "From: \"" . preg_replace ("/\"/", "", $fname . " " . $lname) . "\" <" . $email . ">\r\nContent-Type: text/plain; charset=utf-8");
330
- }
331
  /**/
332
- else if (($level = preg_replace ("/[^1-4]/", "", $_POST["role"])) && ($aweber_list_ids = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["level" . $level . "_aweber_list_ids"]))
333
- {
334
- $email = $user->user_email;
335
- $login = $user->user_login;
336
- $fname = ($user->first_name) ? $user->first_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]);
337
- $lname = ($user->last_name) ? $user->last_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]);
338
- /**/
339
- foreach (preg_split ("/[\r\n\t\s;,]+/", $aweber_list_ids) as $aweber_list_id)
340
- @mail ($aweber_list_id . "@aweber.com", "s2Member Subscription Request",/**/
341
- "s2Member Subscription Request\ns2Member w/ PayPal Email ID\nBuyer: " . $fname . " " . $lname . "\n - end.",/**/
342
- "From: \"" . preg_replace ("/\"/", "", $fname . " " . $lname) . "\" <" . $email . ">\r\nContent-Type: text/plain; charset=utf-8");
343
- }
344
  /**/
345
- if (($_POST["role"] === "subscriber" || ($level = preg_replace ("/[^1-4]/", "", $_POST["role"])))/**/
346
- && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_urls"])
347
- {
348
- $email = $user->user_email;
349
- $login = $user->user_login;
350
- $level = ($_POST["role"] === "subscriber") ? "0" : $level;
351
- $fname = ($user->first_name) ? $user->first_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]);
352
- $lname = ($user->last_name) ? $user->last_name : trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]);
353
- /**/
354
- if ($pass = trim (stripslashes ($_POST["pass1"])))
355
- $pass = $pass; /* From the `Users -> Add New` form.
356
- /**/
357
- if (is_array ($cv = preg_split ("/\|/", $_COOKIE["s2member_custom"])))
358
- foreach (preg_split ("/[\r\n\t]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_urls"]) as $url)
359
- if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)))
360
- if (($url = preg_replace ("/%%level%%/i", urlencode ($level), $url)))
361
- if (($url = preg_replace ("/%%user_first_name%%/i", urlencode ($fname), $url)))
362
- if (($url = preg_replace ("/%%user_last_name%%/i", urlencode ($lname), $url)))
363
- if (($url = preg_replace ("/%%user_full_name%%/i", urlencode (trim ($fname . " " . $lname)), $url)))
364
- if (($url = preg_replace ("/%%user_email%%/i", urlencode ($email), $url)))
365
- if (($url = preg_replace ("/%%user_login%%/i", urlencode ($login), $url)))
366
- if (($url = preg_replace ("/%%user_pass%%/i", urlencode ($pass), $url)))
367
- if (($url = trim ($url))) /* Make sure it is not empty. */
368
- ws_plugin__s2member_curlpsr ($url, "s2member=1");
369
- }
370
  /**/
371
  do_action ("s2member_during_configure_user_registration_admin_side");
372
  }
373
  /**/
374
- if (!is_admin () && !defined ("BP_VERSION")) /* This processes Custom Fields. */
375
  {
376
  if (!$user->first_name && ($first_name = trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"])))
377
  update_usermeta ($user_id, "first_name", $first_name) . /* And display name. */
@@ -391,9 +352,28 @@ function ws_plugin__s2member_configure_user_registration ($user_id = FALSE)
391
  }
392
  /**/
393
  update_usermeta ($user_id, "s2member_custom_fields", $fields);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
394
  }
395
- /**/
396
- do_action ("s2member_during_configure_user_registration");
397
  }
398
  /**/
399
  do_action ("s2member_after_configure_user_registration");
@@ -417,12 +397,12 @@ if (!function_exists ("wp_generate_password"))
417
  /**/
418
  $password = ws_plugin__s2member_random_str_gen ($length, $special_chars);
419
  /**/
420
- if (!defined ("BP_VERSION") && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
421
  if (wp_verify_nonce (trim (stripslashes ($_POST["ws_plugin__s2member_registration"])), "ws-plugin--s2member-registration"))
422
  if ($custom = trim (stripslashes ($_POST["ws_plugin__s2member_custom_reg_field_user_pass"])))
423
  $password = $custom;
424
  /**/
425
- return $password; /* No filter here for security purposes. */
426
  }
427
  }
428
  ?>
37
  {
38
  return apply_filters ("s2member_check_register_access", ($users_can_register = "1"));
39
  }
40
+ else if ($pagenow !== "options-general.php" && ($subscr_id = ws_plugin__s2member_decrypt ($_COOKIE["s2member_subscr_id"])) && ($custom = ws_plugin__s2member_decrypt ($_COOKIE["s2member_custom"])) && preg_match ("/^[1-4](\:|$)/", ($level = ws_plugin__s2member_decrypt ($_COOKIE["s2member_level"]))))
41
  {
42
  global $wpdb; /* Global database object reference. */
43
  /**/
44
+ if (!$usermeta = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = 's2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($subscr_id) . "' LIMIT 1"))
45
  {
46
  return apply_filters ("s2member_check_register_access", ($users_can_register = "1"));
47
  }
91
  echo '<p>' . "\n";
92
  echo '<label>' . "\n";
93
  echo 'Password *' . "\n";
94
+ echo '<input aria-required="true" type="password" maxlength="100" name="ws_plugin__s2member_custom_reg_field_user_pass" id="ws-plugin--s2member-custom-reg-field-user-pass" class="ws-plugin--s2member-custom-reg-field input" size="25" tabindex="' . esc_attr (($tabindex = $tabindex + 1)) . '" value="' . format_to_edit (trim (stripslashes ($_POST["ws_plugin__s2member_custom_reg_field_user_pass"]))) . '" />' . "\n";
95
  echo '</label>' . "\n";
96
  echo '</p>';
97
  }
99
  echo '<p>' . "\n";
100
  echo '<label>' . "\n";
101
  echo 'First Name *' . "\n";
102
+ echo '<input aria-required="true" type="text" maxlength="100" name="ws_plugin__s2member_custom_reg_field_first_name" id="ws-plugin--s2member-custom-reg-field-first-name" class="ws-plugin--s2member-custom-reg-field input" size="25" tabindex="' . esc_attr (($tabindex = $tabindex + 1)) . '" value="' . format_to_edit (trim (stripslashes ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]))) . '" />' . "\n";
103
  echo '</label>' . "\n";
104
  echo '</p>';
105
  /**/
106
  echo '<p>' . "\n";
107
  echo '<label>' . "\n";
108
  echo 'Last Name *' . "\n";
109
+ echo '<input aria-required="true" type="text" maxlength="100" name="ws_plugin__s2member_custom_reg_field_last_name" id="ws-plugin--s2member-custom-reg-field-last-name" class="ws-plugin--s2member-custom-reg-field input" size="25" tabindex="' . esc_attr (($tabindex = $tabindex + 1)) . '" value="' . format_to_edit (trim (stripslashes ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]))) . '" />' . "\n";
110
  echo '</label>' . "\n";
111
  echo '</p>';
112
  /**/
121
  echo '<label>' . "\n";
122
  echo esc_html ($field) . (($req) ? " *" : "") . "\n";
123
  $field = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field));
124
+ echo '<input' . $req . ' type="text" maxlength="100" name="ws_plugin__s2member_custom_reg_field_' . esc_attr ($field) . '" id="ws-plugin--s2member-custom-reg-field-' . esc_attr (preg_replace ("/_/", "-", $field)) . '" class="ws-plugin--s2member-custom-reg-field input" size="25" tabindex="' . esc_attr (($tabindex = $tabindex + 1)) . '" value="' . format_to_edit (trim (stripslashes ($_POST["ws_plugin__s2member_custom_reg_field_" . $field]))) . '" />' . "\n";
125
  echo '</label>' . "\n";
126
  echo '</p>';
127
  }
128
  }
129
  /**/
130
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && ws_plugin__s2member_list_servers_integrated ())
131
+ {
132
+ echo '<p>' . "\n";
133
+ echo '<label>' . "\n";
134
+ echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-opt-in" tabindex="' . esc_attr (($tabindex = $tabindex + 1)) . '" value="1"' . (((empty ($_POST) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_POST["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '') . ' />' . "\n";
135
+ echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"] . "\n";
136
+ echo '</label>' . "\n";
137
+ echo '</p>';
138
+ }
139
+ /**/
140
  do_action ("s2member_during_custom_registration_fields");
141
  }
142
  /**/
145
  return;
146
  }
147
  /*
148
+ This adds an opt-in checkbox to the BuddyPress signup form.
149
+ Attach to: add_action("bp_before_registration_submit_buttons");
150
+ */
151
+ function ws_plugin__s2member_opt_in_4bp ()
152
+ {
153
+ do_action ("s2member_before_opt_in_4bp");
154
+ /**/
155
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && ws_plugin__s2member_list_servers_integrated ())
156
+ {
157
+ echo '<div class="s2member-opt-in-4bp" style="' . apply_filters ("s2member_opt_in_4bp_styles", "clear:both; padding-top:10px; margin-left:-3px;") . '">' . "\n";
158
+ /**/
159
+ echo '<p>' . "\n";
160
+ echo '<label>' . "\n";
161
+ echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-opt-in" value="1"' . (((empty ($_POST) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_POST["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '') . ' />' . "\n";
162
+ echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"] . "\n";
163
+ echo '</label>' . "\n";
164
+ echo '</p>';
165
+ /**/
166
+ echo '</div>' . "\n";
167
+ /**/
168
+ do_action ("s2member_during_opt_in_4bp");
169
+ }
170
+ /**/
171
+ do_action ("s2member_after_opt_in_4bp");
172
+ /**/
173
+ return;
174
+ }
175
+ /*
176
  Generates registration links.
177
  */
178
  function ws_plugin__s2member_register_link_gen ($subscr_id = FALSE, $custom = FALSE, $item_number = FALSE, $shrink = TRUE)
195
  /*
196
  Handles registration links.
197
  Attach to: add_action("init");
 
198
  */
199
  function ws_plugin__s2member_register ()
200
  {
201
  do_action ("s2member_before_register");
202
  /**/
203
+ if ($_GET["s2member_register"]) /* If they're attempting to access the registration system. */
204
  {
205
  if (is_array ($register = preg_split ("/\:\.\:\|\:\.\:/", ws_plugin__s2member_decrypt ($_GET["s2member_register"]))))
206
  {
207
  if (count ($register) === 4 && $register[0] === "subscr_id_custom_item_number" && $register[1] && $register[2] && $register[3])
208
  {
209
+ setcookie ("s2member_subscr_id", ws_plugin__s2member_encrypt ($register[1]), time () + 31556926, "/");
210
+ setcookie ("s2member_custom", ws_plugin__s2member_encrypt ($register[2]), time () + 31556926, "/");
211
+ setcookie ("s2member_level", ws_plugin__s2member_encrypt ($register[3]), time () + 31556926, "/");
212
  /**/
213
  do_action ("s2member_during_register");
214
  /**/
225
  /*
226
  Function for configuring new users.
227
  Attach to: add_action("user_register");
 
228
  */
229
  function ws_plugin__s2member_configure_user_registration ($user_id = FALSE)
230
  {
231
  global $wpdb; /* Global database object may be required for this routine. */
232
+ static $processed; /* Prevents duplicate processing. */
233
  /**/
234
  do_action ("s2member_before_configure_user_registration");
235
  /**/
237
  {
238
  ws_plugin__s2member_email_config (); /* Configures From: header that will be used in new user notifications. */
239
  /**/
240
+ if (!is_admin () /* Only run this particular routine whenever a Member [1-4] is registering themselves with cookies. */
241
+ && ($subscr_id = ws_plugin__s2member_decrypt ($_COOKIE["s2member_subscr_id"])) && ($custom = ws_plugin__s2member_decrypt ($_COOKIE["s2member_custom"])) && preg_match ("/^[1-4](\:|$)/", ($level = ws_plugin__s2member_decrypt ($_COOKIE["s2member_level"])))/**/
242
+ && (!$usermeta = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = 's2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($subscr_id) . "' LIMIT 1")))
243
+ /* ^ This is for security ^ It checks the database to make sure the User/Member has not already registered in the past, with the same PayPal Subscr. ID. */
244
  {
245
+ $processed = "yes"; /* Mark this as yes, to indicate that a routine was successfully processed. */
246
  /**/
247
+ list ($level, $ccaps) = preg_split ("/\:/", $level, 2);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
  /**/
249
+ $email = $user->user_email;
250
+ $login = $user->user_login;
251
+ $ip = $_SERVER["REMOTE_ADDR"];
252
+ $cv = preg_split ("/\|/", $custom);
253
+ $fname = (!$user->first_name) ? trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]) : $user->first_name;
254
+ $lname = (!$user->last_name) ? trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]) : $user->last_name;
255
+ $name = trim ($fname . " " . $lname);
256
+ /**/
257
+ if (!$pass) /* s2Member password? */
258
+ if ($GLOBALS["s2member_password"])
259
+ $pass = $GLOBALS["s2member_password"];
260
+ /**/
261
+ if (!$pass) /* Also try to get the password from BuddyPress. */
262
+ if ($_POST["signup_password"]) /* Field used by BuddyPress. */
263
+ $pass = trim (stripslashes ($_POST["signup_password"]));
264
+ /**/
265
+ $opt_in = (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] || $_POST["ws_plugin__s2member_custom_reg_field_opt_in"]) ? true : false;
266
+ /**/
267
+ $user->set_role ("s2member_level" . $level);
268
+ /**/
269
+ if ($ccaps) /* Add custom capabilities. */
270
+ foreach (preg_split ("/[\r\n\t\s;,]+/", $ccaps) as $ccap)
271
+ if (strlen ($ccap)) /* Don't add empty capabilities. */
272
+ $user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
273
+ /**/
274
+ update_usermeta ($user_id, "s2member_subscr_id", $subscr_id);
275
+ update_usermeta ($user_id, "s2member_custom", $custom);
276
+ /**/
277
+ do_action ("s2member_during_configure_user_registration_front_side");
278
+ }
279
+ /**/
280
+ else if (!is_admin ()) /* Only run this particular routine whenever a Free Subscriber is registering themselves. */
281
+ {
282
+ $processed = "yes"; /* Mark this as yes, to indicate that a routine was successfully processed. */
283
+ /**/
284
+ list ($level, $ccaps) = preg_split ("/\:/", "0:", 2); /* Colon separated level:custom_capability. */
285
+ /**/
286
+ $email = $user->user_email;
287
+ $login = $user->user_login;
288
+ $ip = $_SERVER["REMOTE_ADDR"];
289
+ $cv = preg_split ("/\|/", ""); /* Not applicable here. */
290
+ $fname = (!$user->first_name) ? trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]) : $user->first_name;
291
+ $lname = (!$user->last_name) ? trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]) : $user->last_name;
292
+ $name = trim ($fname . " " . $lname);
293
+ /**/
294
+ if (!$pass) /* s2Member password? */
295
+ if ($GLOBALS["s2member_password"])
296
+ $pass = $GLOBALS["s2member_password"];
297
+ /**/
298
+ if (!$pass) /* Also try to get the password from BuddyPress. */
299
+ if ($_POST["signup_password"]) /* Field used by BuddyPress. */
300
+ $pass = trim (stripslashes ($_POST["signup_password"]));
301
+ /**/
302
+ $opt_in = (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] || $_POST["ws_plugin__s2member_custom_reg_field_opt_in"]) ? true : false;
303
+ /**/
304
+ do_action ("s2member_during_configure_user_registration_front_side");
305
  }
306
  /**/
307
  else if (is_admin () && preg_match ("/wp-admin\/user-new\.php/", $_POST["_wp_http_referer"]) && preg_match ("/^(subscriber|s2member_level[1-4])$/", $_POST["role"]))
308
  {
309
+ $processed = "yes"; /* Mark this as yes, to indicate that a routine was successfully processed. */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  /**/
311
+ $level = ($_POST["role"] === "subscriber") ? "0" : preg_replace ("/[^1-4]/", "", $_POST["role"]);
312
+ $ccaps = ""; /* Custom Capabilities are not applicable here. */
 
 
 
 
 
 
 
 
 
 
 
 
 
313
  /**/
314
+ $email = $user->user_email;
315
+ $login = $user->user_login;
316
+ $ip = ""; /* N/Applicable. */
317
+ $cv = preg_split ("/\|/", "");
318
+ $fname = (!$user->first_name) ? trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]) : $user->first_name;
319
+ $lname = (!$user->last_name) ? trim ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]) : $user->last_name;
320
+ $name = trim ($fname . " " . $lname);
 
 
 
 
 
321
  /**/
322
+ if (!$pass) /* s2Member password? */
323
+ if ($GLOBALS["s2member_password"])
324
+ $pass = $GLOBALS["s2member_password"];
 
 
 
 
 
 
 
 
 
325
  /**/
326
+ if (!$pass) /* Also try the `Users -> Add New` form. */
327
+ if ($_POST["pass1"]) /* Field used by admin form. */
328
+ $pass = trim (stripslashes ($_POST["pass1"]));
329
+ /**/
330
+ $opt_in = (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] || $_POST["ws_plugin__s2member_custom_reg_field_opt_in"]) ? true : false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  /**/
332
  do_action ("s2member_during_configure_user_registration_admin_side");
333
  }
334
  /**/
335
+ if ($processed === "yes") /* If registration was processed by one of the routines above. */
336
  {
337
  if (!$user->first_name && ($first_name = trim ($_POST["ws_plugin__s2member_custom_reg_field_first_name"])))
338
  update_usermeta ($user_id, "first_name", $first_name) . /* And display name. */
352
  }
353
  /**/
354
  update_usermeta ($user_id, "s2member_custom_fields", $fields);
355
+ /**/
356
+ ws_plugin__s2member_process_list_servers ($level, $email, $fname, $lname, $ip, $opt_in);
357
+ /**/
358
+ if ($urls = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_urls"])
359
+ foreach (preg_split ("/[\r\n\t]+/", $urls) as $url) /* Notify each of the urls. */
360
+ if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)))
361
+ if (($url = preg_replace ("/%%level%%/i", urlencode ($level), $url)))
362
+ if (($url = preg_replace ("/%%user_first_name%%/i", urlencode ($fname), $url)))
363
+ if (($url = preg_replace ("/%%user_last_name%%/i", urlencode ($lname), $url)))
364
+ if (($url = preg_replace ("/%%user_full_name%%/i", urlencode ($name), $url)))
365
+ if (($url = preg_replace ("/%%user_email%%/i", urlencode ($email), $url)))
366
+ if (($url = preg_replace ("/%%user_login%%/i", urlencode ($login), $url)))
367
+ if (($url = preg_replace ("/%%user_pass%%/i", urlencode ($pass), $url)))
368
+ if (($url = trim ($url))) /* Make sure it is not empty. */
369
+ ws_plugin__s2member_curlpsr ($url, "s2member=1");
370
+ /**/
371
+ setcookie ("s2member_subscr_id", "", time () + 31556926, "/");
372
+ setcookie ("s2member_custom", "", time () + 31556926, "/");
373
+ setcookie ("s2member_level", "", time () + 31556926, "/");
374
+ /**/
375
+ do_action ("s2member_during_configure_user_registration");
376
  }
 
 
377
  }
378
  /**/
379
  do_action ("s2member_after_configure_user_registration");
397
  /**/
398
  $password = ws_plugin__s2member_random_str_gen ($length, $special_chars);
399
  /**/
400
+ if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"])
401
  if (wp_verify_nonce (trim (stripslashes ($_POST["ws_plugin__s2member_registration"])), "ws-plugin--s2member-registration"))
402
  if ($custom = trim (stripslashes ($_POST["ws_plugin__s2member_custom_reg_field_user_pass"])))
403
  $password = $custom;
404
  /**/
405
+ return ($GLOBALS["s2member_password"] = $password);
406
  }
407
  }
408
  ?>
includes/functions/utilities.inc.php CHANGED
@@ -41,6 +41,34 @@ function ws_plugin__s2member_array_unique ($array = FALSE)
41
  }
42
  }
43
  /*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  Function that buffers ( gets ) function output.
45
  */
46
  function ws_plugin__s2member_get ($function = FALSE)
41
  }
42
  }
43
  /*
44
+ Function that searches a multi-dimensional array
45
+ using a regular expression match against array values.
46
+ */
47
+ function ws_plugin__s2member_regex_in_array ($regex = FALSE, $array = FALSE)
48
+ {
49
+ if ($regex && is_array ($array))
50
+ {
51
+ foreach ($array as $value)
52
+ {
53
+ if (is_array ($value)) /* Recursive function call. */
54
+ {
55
+ if (ws_plugin__s2member_regex_in_array ($regex, $value))
56
+ return true;
57
+ }
58
+ /**/
59
+ else if (is_string ($value)) /* Must be a string. */
60
+ {
61
+ if (@preg_match ($regex, $value))
62
+ return true;
63
+ }
64
+ }
65
+ /**/
66
+ return false;
67
+ }
68
+ else /* False. */
69
+ return false;
70
+ }
71
+ /*
72
  Function that buffers ( gets ) function output.
73
  */
74
  function ws_plugin__s2member_get ($function = FALSE)
includes/hooks.inc.php CHANGED
@@ -42,6 +42,7 @@ add_filter ("pre_option_default_role", "ws_plugin__s2member_force_default_role")
42
  add_filter ("pre_option_users_can_register", "ws_plugin__s2member_check_register_access");
43
  add_action ("user_register", "ws_plugin__s2member_configure_user_registration");
44
  add_action ("register_form", "ws_plugin__s2member_custom_registration_fields");
 
45
  /**/
46
  add_action ("wp_login", "ws_plugin__s2member_login_redirect");
47
  add_action ("login_head", "ws_plugin__s2member_login_header_styles");
42
  add_filter ("pre_option_users_can_register", "ws_plugin__s2member_check_register_access");
43
  add_action ("user_register", "ws_plugin__s2member_configure_user_registration");
44
  add_action ("register_form", "ws_plugin__s2member_custom_registration_fields");
45
+ add_action ("bp_before_registration_submit_buttons", "ws_plugin__s2member_opt_in_4bp");
46
  /**/
47
  add_action ("wp_login", "ws_plugin__s2member_login_redirect");
48
  add_action ("login_head", "ws_plugin__s2member_login_header_styles");
includes/menu-pages/api-ops.inc.php CHANGED
@@ -118,8 +118,7 @@ echo '<li><code>%%user_last_name%% = The Last Name of the Member who registered
118
  echo '<li><code>%%user_full_name%% = The Full Name ( First & Last ) of the Member who registered their Username</code></li>' . "\n";
119
  echo '<li><code>%%user_email%% = The Email Address of the Member who registered their Username.</code></li>' . "\n";
120
  echo '<li><code>%%user_login%% = The Username the Member selected during registration.</code></li>' . "\n";
121
- echo '<li><code>%%user_pass%% = Is only filled when you\'re allowing Custom Passwords.<br />' ./**/
122
- '<em>See: s2Member -> General Options -> Custom Registration Fields.</em></code></li>' . "\n";
123
  echo '</ul>' . "\n";
124
  echo '<strong>Custom replacement codes can also be inserted using these instructions:</strong>' . "\n";
125
  echo '<ul>' . "\n";
118
  echo '<li><code>%%user_full_name%% = The Full Name ( First & Last ) of the Member who registered their Username</code></li>' . "\n";
119
  echo '<li><code>%%user_email%% = The Email Address of the Member who registered their Username.</code></li>' . "\n";
120
  echo '<li><code>%%user_login%% = The Username the Member selected during registration.</code></li>' . "\n";
121
+ echo '<li><code>%%user_pass%% = The Password selected or generated during registration.</code></li>' . "\n";
 
122
  echo '</ul>' . "\n";
123
  echo '<strong>Custom replacement codes can also be inserted using these instructions:</strong>' . "\n";
124
  echo '<ul>' . "\n";
includes/menu-pages/els-ops.inc.php CHANGED
@@ -254,6 +254,58 @@ echo '</div>' . "\n";
254
  /**/
255
  echo '</div>' . "\n";
256
  /**/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  echo '<div class="ws-menu-page-group" title="Other List Server Integration Methods">' . "\n";
258
  /**/
259
  echo '<div class="ws-menu-page-section ws-plugin--s2member-other-lists-section">' . "\n";
254
  /**/
255
  echo '</div>' . "\n";
256
  /**/
257
+ echo '<div class="ws-menu-page-group" title="Registration / Double Opt-In Box?">' . "\n";
258
+ /**/
259
+ echo '<div class="ws-menu-page-section ws-plugin--s2member-opt-in-section">' . "\n";
260
+ echo '<h3>Double Opt-In Checkbox Field ( optional )</h3>' . "\n";
261
+ echo '<p>A Double Opt-In Checkbox will ONLY be displayed, if you\'ve integrated one <em>or more</em> List Servers ( in the sections above ).' . ((defined ("BP_VERSION")) ? ' With BuddyPress installed, the Checkbox will only be displayed if your BuddyPress theme supports <code>do_action("bp_before_registration_submit_buttons")</code>. Almost all BuddyPress themes support this. If yours does not, you can add it in.' : '') . '</p>' . "\n";
262
+ /**/
263
+ echo '<table class="form-table">' . "\n";
264
+ echo '<tbody>' . "\n";
265
+ echo '<tr class="ws-plugin--s2member-custom-reg-opt-in-label-row"' . ((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"]) ? ' style="display:none;"' : '') . '>' . "\n";
266
+ /**/
267
+ echo '<th>' . "\n";
268
+ echo '<label for="ws-plugin--s2member-custom-reg-opt-in-label">' . "\n";
269
+ echo 'Double Opt-In Checkbox Label:' . "\n";
270
+ echo '</label>' . "\n";
271
+ echo '</th>' . "\n";
272
+ /**/
273
+ echo '</tr>' . "\n";
274
+ echo '<tr class="ws-plugin--s2member-custom-reg-opt-in-label-row"' . ((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"]) ? ' style="display:none;"' : '') . '>' . "\n";
275
+ /**/
276
+ echo '<td>' . "\n";
277
+ echo '<input type="text" name="ws_plugin__s2member_custom_reg_opt_in_label" id="ws-plugin--s2member-custom-reg-opt-in-label" value="' . format_to_edit ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"]) . '" /><br />' . "\n";
278
+ echo 'Example: <code><img src="' . $GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["dir_url"] . '/images/' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) ? 'checked' : 'unchecked') . '.png" class="ws-plugin--s2member-custom-reg-opt-in-label-prev-img ws-menu-page-img-16" style="vertical-align:middle;" alt="" /> Your Label will appear next to a Checkbox.</code>' . "\n";
279
+ echo '</td>' . "\n";
280
+ /**/
281
+ echo '</tr>' . "\n";
282
+ echo '<tr>' . "\n";
283
+ /**/
284
+ echo '<th>' . "\n";
285
+ echo '<label for="ws-plugin--s2member-custom-reg-opt-in">' . "\n";
286
+ echo 'Require Double Opt-In Checkbox?' . "\n";
287
+ echo '</label>' . "\n";
288
+ echo '</th>' . "\n";
289
+ /**/
290
+ echo '</tr>' . "\n";
291
+ echo '<tr>' . "\n";
292
+ /**/
293
+ echo '<td>' . "\n";
294
+ echo '<select name="ws_plugin__s2member_custom_reg_opt_in" id="ws-plugin--s2member-custom-reg-opt-in">' . "\n";
295
+ echo '<option value="1"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) ? ' selected="selected"' : '') . '>Yes ( the Box MUST be checked — checked by default )</option>' . "\n";
296
+ echo '<option value="2"' . (($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 2) ? ' selected="selected"' : '') . '>Yes ( the Box MUST be checked — unchecked by default )</option>' . "\n";
297
+ echo '<option value="0"' . ((!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"]) ? ' selected="selected"' : '') . '>No ( disable — do NOT display or require the Checkbox )</option>' . "\n";
298
+ echo '</select><br />' . "\n";
299
+ echo 'An email confirmation will NOT be sent to the User, unless the Box is checked, or you\'ve disabled the Box; by choosing <code>No</code>.' . "\n";
300
+ echo '</td>' . "\n";
301
+ /**/
302
+ echo '</tr>' . "\n";
303
+ echo '</tbody>' . "\n";
304
+ echo '</table>' . "\n";
305
+ echo '</div>' . "\n";
306
+ /**/
307
+ echo '</div>' . "\n";
308
+ /**/
309
  echo '<div class="ws-menu-page-group" title="Other List Server Integration Methods">' . "\n";
310
  /**/
311
  echo '<div class="ws-menu-page-section ws-plugin--s2member-other-lists-section">' . "\n";
includes/menu-pages/menu-pages.js CHANGED
@@ -83,7 +83,7 @@ jQuery(document).ready (function($)
83
  /**/
84
  $('input.ws-menu-page-media-btn').filter (function() /* Only those that have a rel attribute. */
85
  {
86
- return($(this).attr ('rel')) ? true : false; /* Must have rel targeting an input id. */
87
  })/**/
88
  .click (function() /* Attach click events to media buttons with send_to_editor(). */
89
  {
@@ -164,6 +164,25 @@ jQuery(document).ready (function($)
164
  };
165
  }
166
  /**/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  else if (location.href.match (/page\=ws-plugin--s2member-buttons/))
168
  {
169
  $('select#ws-plugin--s2member-level1-term, select#ws-plugin--s2member-level2-term, select#ws-plugin--s2member-level3-term, select#ws-plugin--s2member-level4-term, select#ws-plugin--s2member-modification-term').change (function()
83
  /**/
84
  $('input.ws-menu-page-media-btn').filter (function() /* Only those that have a rel attribute. */
85
  {
86
+ return ($(this).attr ('rel')) ? true : false; /* Must have rel targeting an input id. */
87
  })/**/
88
  .click (function() /* Attach click events to media buttons with send_to_editor(). */
89
  {
164
  };
165
  }
166
  /**/
167
+ else if (location.href.match (/page\=ws-plugin--s2member-els-ops/))
168
+ {
169
+ $('select#ws-plugin--s2member-custom-reg-opt-in').change (function()
170
+ {
171
+ var $this = $(this), val = $this.val ();
172
+ var $rows = $('tr.ws-plugin--s2member-custom-reg-opt-in-label-row');
173
+ var $prevImg = $('img.ws-plugin--s2member-custom-reg-opt-in-label-prev-img');
174
+ /**/
175
+ if (val <= 0) /* Checkbox disabled. */
176
+ $rows.css ('display', 'none'), $prevImg.attr ('src', $prevImg.attr ('src').replace (/\/checked\.png$/, '/unchecked.png'));
177
+ /**/
178
+ else if (val == 1) /* Enabled, checked by default. */
179
+ $rows.css ('display', ''), $prevImg.attr ('src', $prevImg.attr ('src').replace (/\/unchecked\.png$/, '/checked.png'));
180
+ /**/
181
+ else if (val == 2) /* Enabled, unchecked by default. */
182
+ $rows.css ('display', ''), $prevImg.attr ('src', $prevImg.attr ('src').replace (/\/checked\.png$/, '/unchecked.png'));
183
+ });
184
+ }
185
+ /**/
186
  else if (location.href.match (/page\=ws-plugin--s2member-buttons/))
187
  {
188
  $('select#ws-plugin--s2member-level1-term, select#ws-plugin--s2member-level2-term, select#ws-plugin--s2member-level3-term, select#ws-plugin--s2member-level4-term, select#ws-plugin--s2member-modification-term').change (function()
includes/syscon.inc.php CHANGED
@@ -72,6 +72,8 @@ function ws_plugin__s2member_configure_options_and_their_defaults ($options = FA
72
  /**/
73
  "custom_reg_fields" => "", /* A comma delimited list of custom fields to collect/use. */
74
  "custom_reg_password" => "0", /* Allow users to register their own custom password? */
 
 
75
  /**/
76
  "allow_subscribers_in" => "0", /* Allow subscribers to access the login_welcome_page? */
77
  "force_admin_lockouts" => "0", /* Redirects admin pages/profile to the login_welcome_page. */
@@ -221,6 +223,12 @@ function ws_plugin__s2member_configure_options_and_their_defaults ($options = FA
221
  else if ($key === "custom_reg_password" && (!is_string ($value) || !is_numeric ($value)))
222
  $value = $default_options[$key];
223
  /**/
 
 
 
 
 
 
224
  else if ($key === "allow_subscribers_in" && (!is_string ($value) || !is_numeric ($value)))
225
  $value = $default_options[$key];
226
  /**/
72
  /**/
73
  "custom_reg_fields" => "", /* A comma delimited list of custom fields to collect/use. */
74
  "custom_reg_password" => "0", /* Allow users to register their own custom password? */
75
+ "custom_reg_opt_in" => "1", /* Use a double opt-in checkbox on the registration form? */
76
+ "custom_reg_opt_in_label" => "Yes, I want to receive updates via email.", /* Label. */
77
  /**/
78
  "allow_subscribers_in" => "0", /* Allow subscribers to access the login_welcome_page? */
79
  "force_admin_lockouts" => "0", /* Redirects admin pages/profile to the login_welcome_page. */
223
  else if ($key === "custom_reg_password" && (!is_string ($value) || !is_numeric ($value)))
224
  $value = $default_options[$key];
225
  /**/
226
+ else if ($key === "custom_reg_opt_in" && (!is_string ($value) || !is_numeric ($value)))
227
+ $value = $default_options[$key];
228
+ /**/
229
+ else if ($key === "custom_reg_opt_in_label" && (!is_string ($value) || !strlen ($value)))
230
+ $value = $default_options[$key];
231
+ /**/
232
  else if ($key === "allow_subscribers_in" && (!is_string ($value) || !is_numeric ($value)))
233
  $value = $default_options[$key];
234
  /**/
readme.txt CHANGED
@@ -1,7 +1,7 @@
1
  === s2Member ( Membership w/ PayPal® Integration ) also works w/ BuddyPress ===
2
 
3
- Version: 2.9.3
4
- Stable tag: 2.9.3
5
  Framework: WS-P-2.1
6
 
7
  WordPress Compatible: yes
@@ -101,6 +101,12 @@ Archived releases of s2Member are maintained [here](http://wordpress.org/extend/
101
 
102
  == Changelog ==
103
 
 
 
 
 
 
 
104
  = 2.9.3 =
105
  * Documentation fix. `s2Member -> API Scripting -> Advanced Conditionals -> Example #5` contained a PHP syntax error. This has been corrected in v2.9.3.
106
  * Bug fix. Infinite redirection loop on Download Limit Exceeded Page. This was possible under certain circumstances, based on configuration. Resolved in v2.9.3.
1
  === s2Member ( Membership w/ PayPal® Integration ) also works w/ BuddyPress ===
2
 
3
+ Version: 2.9.4
4
+ Stable tag: 2.9.4
5
  Framework: WS-P-2.1
6
 
7
  WordPress Compatible: yes
101
 
102
  == Changelog ==
103
 
104
+ = 2.9.4 =
105
+ * Bug fix in %%current_user_login%% for Special Redirection URLs. Was not processing correctly. This has been resolved in 2.9.4+.
106
+ * Bug fix in AWeber®/MailChimp® integration for Free Subscriber registrations. Specifically, those originating from the front-end.
107
+ * Extra security hardening. `MCRYPT_RIJNDAEL_256 / CBC` now being utilized in Registration Access Cookies.
108
+ * New feature. s2Member now supports a custom Double Opt-In Checkbox for its List Server integrations. See `s2Member -> API List Servers -> Double Opt-In`. This is also compatible with BuddyPress registration forms.
109
+
110
  = 2.9.3 =
111
  * Documentation fix. `s2Member -> API Scripting -> Advanced Conditionals -> Example #5` contained a PHP syntax error. This has been corrected in v2.9.3.
112
  * Bug fix. Infinite redirection loop on Download Limit Exceeded Page. This was possible under certain circumstances, based on configuration. Resolved in v2.9.3.
s2member.php CHANGED
@@ -9,8 +9,8 @@ along with this software. In the main directory, see: /licensing/
9
  If not, see: <http://www.gnu.org/licenses/>.
10
  */
11
  /*
12
- Version: 2.9.3
13
- Stable tag: 2.9.3
14
  Framework: WS-P-2.1
15
 
16
  WordPress Compatible: yes
9
  If not, see: <http://www.gnu.org/licenses/>.
10
  */
11
  /*
12
+ Version: 2.9.4
13
+ Stable tag: 2.9.4
14
  Framework: WS-P-2.1
15
 
16
  WordPress Compatible: yes