Version Description
- Custom Fields ( new features ). s2Member is now equipped with a VERY powerful set of features; designed to extend the functionality of Custom Fields. s2Member now supports Text Fields ( single/multi-line ), Checkboxes ( single/multi-option ), Radio Buttons ( single/multi-option ), and Dropdowns ( single/multi-option ). In addition, with s2Member it is now possible to configure Custom Fields differently for each Membership Level. Other tools: including Validation Formats and Visibility are also available. For full details, check your Dashboard under:
s2Member -> General Options -> Custom Fields
. - Attn Developers ( before upgrading ). Hooks/Filters ( e.g. those related to Custom Fields ) have been modified in ways that may break custom scripts you've created to work with previous versions of s2Member. We suggest dropping all of your Hooks/Filters related to Custom Fields. Instead, use the NEW improved tools w/s2Member v3.2.7+. Please see:
s2Member -> General Options -> Custom Fields
. - BuddyPress/Multisite. A plugin conflict was resolved between BuddyPress/s2Member when both of these plugins were installed on a Multisite Network together. BuddyPress bypasses the default Filter (
pre_site_option_registration
) and instead, it uses:bp_core_get_site_options()
. This has been resolved in s2Member v3.2.6+. - Bug fix. A bug was found in s2Member's handling of Custom Fields columns. This minor bug was conflicting with other plugins that attempt to create User-based columns. This was been resolved in s2Member v3.2.7+.
- New Shortcode attribute. s2Member's PayPal Button Shortcode now accepts a new attribute (
ta="0.00"
, Trial Amount ). In the past, if you intended to offer a "paid" initial period at a different price, you had to use the Full Button Code. Now you can just change theta="0.00"
attribute ( which is easier ). - More informative. s2Member now generates warnings for newbies that create conflicts between their Membership Options Page and Login Welcome Page. s2Member is now capable of detecting the most common conflicts, in order to produce informative messages that assist site owners.
- Login/Registration Design. s2Member v3.2.7+ includes additional customization tools that allow font sizes and font families to be configured for the Login/Registration system. In your Dashboard, go to:
s2Member -> General Options -> Login/Registration Design
. - Bug fix. The Default Profile Editing Panel ( e.g.
/wp-admin/profile.php
) was NOT validating Custom Fields. s2Member v3.2.7 resolves this for Users/Members. Administrators are exempt ( the intended functionality ). - Better instructions inside in the General Options panel for s2Member. Just a few subtle improvements based on User feedback. Hopefully these will make life a little easier for newbies.
Download this release
Release Info
Developer | PriMoThemes |
Plugin | ![]() |
Version | 3.2.7 |
Comparing to | |
See all releases |
Code changes from version 3.2.5 to 3.2.7
- images/add-icon.fla +0 -0
- images/add-icon.png +0 -0
- images/arrow-down-icon.fla +0 -0
- images/arrow-down-icon.png +0 -0
- images/arrow-up-icon.fla +0 -0
- images/arrow-up-icon.png +0 -0
- images/delete-icon.png +0 -0
- images/edit-icon.png +0 -0
- includes/dropins/bridges/_s2member-bbpress-bridge.php +1 -1
- includes/functions/activate-deactivate.inc.php +6 -0
- includes/functions/api-functions.inc.php +12 -0
- includes/functions/config-user-registration.inc.php +598 -0
- includes/functions/css-js-w-globals.inc.php +8 -8
- includes/functions/custom-reg-fields.inc.php +453 -0
- includes/functions/demo-users.inc.php +39 -0
- includes/functions/demotions.inc.php +0 -29
- includes/functions/email-configs.inc.php +19 -1
- includes/functions/force-options.inc.php +271 -0
- includes/functions/list-servers.inc.php +21 -21
- includes/functions/login-customizations.inc.php +32 -15
- includes/functions/menu-pages.inc.php +72 -74
- includes/functions/meta-boxes.inc.php +5 -7
- includes/functions/page-level-access.inc.php +2 -2
- includes/functions/passwords.inc.php +47 -0
- includes/functions/paypal-button.inc.php +4 -8
- includes/functions/post-level-access.inc.php +2 -2
- includes/functions/profile-modifications.inc.php +23 -24
- includes/functions/register-access.inc.php +0 -1387
- includes/functions/sc-get-details.inc.php +8 -30
- includes/functions/separates/paypal-notify.inc.php +2 -0
- includes/functions/separates/paypal-return.inc.php +1 -0
- includes/functions/user-new.inc.php +249 -0
- includes/functions/users-list.inc.php +209 -209
- includes/functions/utilities.inc.php +44 -10
- includes/hooks.inc.php +1 -0
- includes/menu-pages/code-samples/sc-s2-conditional-supplements-1.php +3 -0
- includes/menu-pages/info.inc.php +1 -1
- includes/menu-pages/jquery-ui-effects.js +220 -0
- includes/menu-pages/json-functions.js +1 -0
- includes/menu-pages/menu-pages-s-min.js +1 -1
- includes/menu-pages/menu-pages-s.css +110 -0
- includes/menu-pages/menu-pages-s.js +652 -3
- includes/menu-pages/options.inc.php +72 -14
- includes/menu-pages/paypal-buttons.inc.php +17 -17
- includes/profile.inc.php +67 -66
- includes/s2member-min.js +1 -1
- includes/s2member.css +13 -3
- includes/s2member.js +211 -35
- includes/syscon.inc.php +388 -379
- includes/templates/shortcodes/paypal-checkout-button-shortcode.html +1 -1
- readme.txt +20 -9
- s2member.php +6 -6
images/add-icon.fla
ADDED
Binary file
|
images/add-icon.png
ADDED
Binary file
|
images/arrow-down-icon.fla
ADDED
Binary file
|
images/arrow-down-icon.png
ADDED
Binary file
|
images/arrow-up-icon.fla
ADDED
Binary file
|
images/arrow-up-icon.png
ADDED
Binary file
|
images/delete-icon.png
ADDED
Binary file
|
images/edit-icon.png
ADDED
Binary file
|
includes/dropins/bridges/_s2member-bbpress-bridge.php
CHANGED
@@ -18,8 +18,8 @@ Donate link: http://www.primothemes.com/donate/
|
|
18 |
Plugin Name: s2Member Bridge
|
19 |
Pro Module / Prices: http://www.s2member.com/prices/
|
20 |
Forum URI: http://www.primothemes.com/forums/viewforum.php?f=4
|
21 |
-
Plugin URI: http://www.primothemes.com/post/s2member-membership-plugin-with-paypal/
|
22 |
Professional Installation URI: http://www.primothemes.com/forums/viewtopic.php?f=4&t=107
|
|
|
23 |
Description: Blocks all non-Member access to bbPress® forums. Only the login-page is available. Forum registration is redirected to your Membership Options Page for s2Member ( on your main WordPress® installation ). This way, a visitor can signup on your site, and gain Membership Access to your forums. This plugin will NOT work, until you've successfully integrated WordPress® into bbPress®. See: `bbPress® -> Settings -> WordPress® Integration`.
|
24 |
Tags: membership, members, member, register, signup, paypal, pay pal, s2member, subscriber, members only, bbpress, bb press, forums, forum, buddypress, buddy press, buddy press compatible, shopping cart, checkout, api, options panel included, websharks framework, w3c validated code, multi widget support, includes extensive documentation, highly extensible
|
25 |
*/
|
18 |
Plugin Name: s2Member Bridge
|
19 |
Pro Module / Prices: http://www.s2member.com/prices/
|
20 |
Forum URI: http://www.primothemes.com/forums/viewforum.php?f=4
|
|
|
21 |
Professional Installation URI: http://www.primothemes.com/forums/viewtopic.php?f=4&t=107
|
22 |
+
Plugin URI: http://www.primothemes.com/post/product/s2member-membership-plugin-with-paypal/
|
23 |
Description: Blocks all non-Member access to bbPress® forums. Only the login-page is available. Forum registration is redirected to your Membership Options Page for s2Member ( on your main WordPress® installation ). This way, a visitor can signup on your site, and gain Membership Access to your forums. This plugin will NOT work, until you've successfully integrated WordPress® into bbPress®. See: `bbPress® -> Settings -> WordPress® Integration`.
|
24 |
Tags: membership, members, member, register, signup, paypal, pay pal, s2member, subscriber, members only, bbpress, bb press, forums, forum, buddypress, buddy press, buddy press compatible, shopping cart, checkout, api, options panel included, websharks framework, w3c validated code, multi widget support, includes extensive documentation, highly extensible
|
25 |
*/
|
includes/functions/activate-deactivate.inc.php
CHANGED
@@ -184,6 +184,12 @@ if (!function_exists ("ws_plugin__s2member_activate"))
|
|
184 |
$wpdb->query ("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '\_transient\_%'");
|
185 |
}
|
186 |
/**/
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
$notice = '<strong>s2Member</strong> has been <strong>re-activated</strong>, with the latest version.<br />';
|
188 |
$notice .= 'You now have version ' . WS_PLUGIN__S2MEMBER_VERSION . '. Your existing configuration remains.';
|
189 |
/**/
|
184 |
$wpdb->query ("DELETE FROM `" . $wpdb->options . "` WHERE `option_name` LIKE '\_transient\_%'");
|
185 |
}
|
186 |
/**/
|
187 |
+
if (!$v || !version_compare ($v, "3.2.6", ">=")) /* Needs to be upgraded? */
|
188 |
+
/* Version 3.2.6 fixed `s2member_ccaps_req` being stored empty and/or w/ one empty element in the array. */
|
189 |
+
{
|
190 |
+
$wpdb->query ("DELETE FROM `" . $wpdb->postmeta . "` WHERE `meta_key` = 's2member_ccaps_req' AND `meta_value` IN('','a:0:{}','a:1:{i:0;s:0:\"\";}')");
|
191 |
+
}
|
192 |
+
/**/
|
193 |
$notice = '<strong>s2Member</strong> has been <strong>re-activated</strong>, with the latest version.<br />';
|
194 |
$notice .= 'You now have version ' . WS_PLUGIN__S2MEMBER_VERSION . '. Your existing configuration remains.';
|
195 |
/**/
|
includes/functions/api-functions.inc.php
CHANGED
@@ -429,4 +429,16 @@ if (!function_exists ("s2member_file_download_key"))
|
|
429 |
return ws_plugin__s2member_file_download_key ($file, $cache_compatible);
|
430 |
}
|
431 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
432 |
?>
|
429 |
return ws_plugin__s2member_file_download_key ($file, $cache_compatible);
|
430 |
}
|
431 |
}
|
432 |
+
/*
|
433 |
+
Retrieves a Custom Field value.
|
434 |
+
$field_id - required argument.
|
435 |
+
$user_id - defaults to current user.
|
436 |
+
*/
|
437 |
+
if (!function_exists ("get_user_field"))
|
438 |
+
{
|
439 |
+
function get_user_field ($field_id = FALSE, $user_id = FALSE)
|
440 |
+
{
|
441 |
+
return ws_plugin__s2member_get_user_field ($field_id, $user_id);
|
442 |
+
}
|
443 |
+
}
|
444 |
?>
|
includes/functions/config-user-registration.inc.php
ADDED
@@ -0,0 +1,598 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 ("Do not access this file directly.");
|
16 |
+
/*
|
17 |
+
Function that adds hidden fields to POST vars on signup.
|
18 |
+
Attach to: add_filter("signup_hidden_fields");
|
19 |
+
|
20 |
+
This can ONLY be fired through wp-signup.php on the front-side.
|
21 |
+
*/
|
22 |
+
if (!function_exists ("ws_plugin__s2member_ms_process_signup_hidden_fields"))
|
23 |
+
{
|
24 |
+
function ws_plugin__s2member_ms_process_signup_hidden_fields ()
|
25 |
+
{
|
26 |
+
do_action ("ws_plugin__s2member_before_ms_process_signup_hidden_fields", get_defined_vars ());
|
27 |
+
/**/
|
28 |
+
if (is_multisite ()) /* This event should ONLY be processed with Multisite Networking, on a Blog Farm. */
|
29 |
+
if (ws_plugin__s2member_is_multisite_farm () && is_main_site () && preg_match ("/\/wp-signup\.php/", $_SERVER["REQUEST_URI"]) && $_POST["stage"] === "validate-user-signup")
|
30 |
+
{
|
31 |
+
foreach ((array)ws_plugin__s2member_trim_deep (stripslashes_deep ($_POST)) as $key => $value)
|
32 |
+
if (preg_match ("/^ws_plugin__s2member_(custom_reg_field|user_new)_/", $key))
|
33 |
+
if ($key = preg_replace ("/_user_new_/", "_custom_reg_field_", $key))
|
34 |
+
echo '<input type="hidden" name="' . esc_attr ($key) . '" value="' . esc_attr (maybe_serialize ($value)) . '" />' . "\n";
|
35 |
+
/**/
|
36 |
+
do_action ("ws_plugin__s2member_during_ms_process_signup_hidden_fields", get_defined_vars ());
|
37 |
+
}
|
38 |
+
/**/
|
39 |
+
do_action ("ws_plugin__s2member_after_ms_process_signup_hidden_fields", get_defined_vars ());
|
40 |
+
}
|
41 |
+
}
|
42 |
+
/*
|
43 |
+
Function that adds customs fields to $meta on signup.
|
44 |
+
Attach to: add_filter("add_signup_meta");
|
45 |
+
|
46 |
+
This can be fired through wp-signup.php on the front-side,
|
47 |
+
or possibly through user-new.php in the admin.
|
48 |
+
*/
|
49 |
+
if (!function_exists ("ws_plugin__s2member_ms_process_signup_meta"))
|
50 |
+
{
|
51 |
+
function ws_plugin__s2member_ms_process_signup_meta ($meta = FALSE)
|
52 |
+
{
|
53 |
+
global $pagenow; /* Need this to detect the current admin page. */
|
54 |
+
/**/
|
55 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
56 |
+
do_action ("ws_plugin__s2member_before_ms_process_signup_meta", get_defined_vars ());
|
57 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
58 |
+
/**/
|
59 |
+
if (is_multisite ()) /* This event should ONLY be processed with Multisite Networking. Either in the admin, or on a Blog Farm through wp-signup.php. */
|
60 |
+
if ((is_admin () && $pagenow === "user-new.php") || (ws_plugin__s2member_is_multisite_farm () && is_main_site () && preg_match ("/\/wp-signup\.php/", $_SERVER["REQUEST_URI"]) && preg_match ("/^validate-(user|blog)-signup$/", $_POST["stage"])))
|
61 |
+
{
|
62 |
+
ws_plugin__s2member_email_config (); /* Configures From: header that will be used in notifications. */
|
63 |
+
/**/
|
64 |
+
foreach ((array)ws_plugin__s2member_trim_deep (stripslashes_deep ($_POST)) as $key => $value)
|
65 |
+
if (preg_match ("/^ws_plugin__s2member_(custom_reg_field|user_new)_/", $key))
|
66 |
+
if ($key = preg_replace ("/_user_new_/", "_custom_reg_field_", $key))
|
67 |
+
$meta["s2member_ms_signup_meta"][$key] = maybe_unserialize ($value);
|
68 |
+
}
|
69 |
+
/**/
|
70 |
+
return apply_filters ("ws_plugin__s2member_ms_process_signup_meta", $meta, get_defined_vars ());
|
71 |
+
}
|
72 |
+
}
|
73 |
+
/*
|
74 |
+
Function for configuring new users.
|
75 |
+
Attach to: add_action("wpmu_activate_user");
|
76 |
+
|
77 |
+
This does NOT fire for a Super Admin managing Network Users.
|
78 |
+
Which is good. A Super Admin will NOT trigger this event.
|
79 |
+
~ They fire wpmu_create_user(), bypassing activation.
|
80 |
+
- through ms-edit.php.
|
81 |
+
|
82 |
+
However, a Super Admin CAN trigger this event by adding a new User through the Users -> Add New menu.
|
83 |
+
~ If they choose to bypass activation; an activation IS fired immediately. Otherwise, it's delayed.
|
84 |
+
- via user-new.php.
|
85 |
+
|
86 |
+
So this function may get fired inside the admin panel ( user-new.php ).
|
87 |
+
Or also during an actual activation; through wp-activate.php.
|
88 |
+
*/
|
89 |
+
if (!function_exists ("ws_plugin__s2member_configure_user_on_ms_user_activation"))
|
90 |
+
{
|
91 |
+
function ws_plugin__s2member_configure_user_on_ms_user_activation ($user_id = FALSE, $password = FALSE, $meta = FALSE)
|
92 |
+
{
|
93 |
+
global $pagenow; /* Need this to detect the current admin page. */
|
94 |
+
/**/
|
95 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
96 |
+
do_action ("ws_plugin__s2member_before_configure_user_on_ms_user_activation", get_defined_vars ());
|
97 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
98 |
+
/**/
|
99 |
+
if (is_multisite ()) /* This event should ONLY be processed with Multisite Networking. */
|
100 |
+
if ((is_admin () && $pagenow === "user-new.php") || (!is_admin () && preg_match ("/\/wp-activate\.php/", $_SERVER["REQUEST_URI"])))
|
101 |
+
{
|
102 |
+
ws_plugin__s2member_configure_user_registration ($user_id, $password, $meta["s2member_ms_signup_meta"]);
|
103 |
+
delete_user_meta ($user_id, "s2member_ms_signup_meta");
|
104 |
+
}
|
105 |
+
/**/
|
106 |
+
do_action ("ws_plugin__s2member_after_configure_user_on_ms_user_activation", get_defined_vars ());
|
107 |
+
/**/
|
108 |
+
return;
|
109 |
+
}
|
110 |
+
}
|
111 |
+
/*
|
112 |
+
Function for configuring new users.
|
113 |
+
Attach to: add_action("wpmu_activate_blog");
|
114 |
+
|
115 |
+
This does NOT fire for a Super Admin managing Network Blogs.
|
116 |
+
~ Actually they do; BUT it's blocked by the routine below.
|
117 |
+
Which is good. A Super Admin should NOT trigger this event.
|
118 |
+
|
119 |
+
This function should ONLY be fired through wp-activate.php.
|
120 |
+
*/
|
121 |
+
if (!function_exists ("ws_plugin__s2member_configure_user_on_ms_blog_activation"))
|
122 |
+
{
|
123 |
+
function ws_plugin__s2member_configure_user_on_ms_blog_activation ($blog_id = FALSE, $user_id = FALSE, $password = FALSE, $title = FALSE, $meta = FALSE)
|
124 |
+
{
|
125 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
126 |
+
do_action ("ws_plugin__s2member_before_configure_user_on_ms_blog_activation", get_defined_vars ());
|
127 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
128 |
+
/**/
|
129 |
+
if (is_multisite ()) /* This event should ONLY be processed with Multisite Networking. */
|
130 |
+
if (!is_admin () && preg_match ("/\/wp-activate\.php/", $_SERVER["REQUEST_URI"])) /* ONLY `wp-activate.php`. */
|
131 |
+
{
|
132 |
+
ws_plugin__s2member_configure_user_registration ($user_id, $password, $meta["s2member_ms_signup_meta"]);
|
133 |
+
delete_user_meta ($user_id, "s2member_ms_signup_meta");
|
134 |
+
}
|
135 |
+
/**/
|
136 |
+
do_action ("ws_plugin__s2member_after_configure_user_on_ms_blog_activation", get_defined_vars ());
|
137 |
+
/**/
|
138 |
+
return;
|
139 |
+
}
|
140 |
+
}
|
141 |
+
/*
|
142 |
+
Function for configuring new users.
|
143 |
+
Attach to: add_action("user_register");
|
144 |
+
|
145 |
+
This also receives Multisite events.
|
146 |
+
Attach to: add_action("wpmu_activate_user");
|
147 |
+
Attach to: add_action("wpmu_activate_blog");
|
148 |
+
|
149 |
+
The Hook `user_register` is also fired by calling:
|
150 |
+
wpmu_create_user()
|
151 |
+
|
152 |
+
This function also receives simulated events from s2Member Pro.
|
153 |
+
*/
|
154 |
+
if (!function_exists ("ws_plugin__s2member_configure_user_registration"))
|
155 |
+
{
|
156 |
+
function ws_plugin__s2member_configure_user_registration ($user_id = FALSE, $password = FALSE, $meta = FALSE)
|
157 |
+
{
|
158 |
+
global $wpdb; /* Global database object may be required for this routine. */
|
159 |
+
global $pagenow; /* Need this to detect the current admin page. */
|
160 |
+
global $current_site, $current_blog; /* Multisite Networking. */
|
161 |
+
static $email_config, $processed; /* No duplicate processing. */
|
162 |
+
/**/
|
163 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
164 |
+
do_action ("ws_plugin__s2member_before_configure_user_registration", get_defined_vars ());
|
165 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
166 |
+
/**/
|
167 |
+
/* With Multisite Networking, we need this to run on `user_register` ahead of `wpmu_activate_user|blog`. */
|
168 |
+
if (!$email_config && ($email_config = true)) /* Anytime this routine is fired; we config email; no exceptions. */
|
169 |
+
ws_plugin__s2member_email_config (); /* Configures From: header that will be used in new user notifications. */
|
170 |
+
/**/
|
171 |
+
if (!$processed /* Process only once. Safeguard this routine against duplicate processing via plugins ( or even WordPress® itself ). */
|
172 |
+
&& (is_array ($_POST = ws_plugin__s2member_trim_deep (stripslashes_deep ($_POST))) || is_array (ws_plugin__s2member_trim_deep (stripslashes_deep ($meta))))/**/
|
173 |
+
/**/
|
174 |
+
/* These negative matches are designed to prevent this routine from running under certain conditions; where we need to wait for `wpmu_activate_user|blog` instead. */
|
175 |
+
&& ! (is_admin () && is_multisite () && $pagenow === "user-new.php" && isset ($_POST["noconfirmation"]) && is_super_admin () && empty ($meta))/**/
|
176 |
+
&& ! (preg_match ("/\/wp-activate\.php/", $_SERVER["REQUEST_URI"]) && empty ($meta)) /* If activating; we MUST have a meta array. */
|
177 |
+
/* The $meta array is ONLY filled by hand-offs from `wpmu_activate_user|blog`. So this is how we check for these events. */
|
178 |
+
/**/
|
179 |
+
&& $user_id && is_object ($user = new WP_User ($user_id)) && $user->ID && ($processed = true)) /* Process only once. */
|
180 |
+
{
|
181 |
+
foreach ((array)$_POST as $key => $value) /* Scan $_POST vars; adding `custom_reg_field` uniformity keys. */
|
182 |
+
if (preg_match ("/^ws_plugin__s2member_user_new_/", $key)) /* Looking for `user_new` keys here. */
|
183 |
+
if ($key = preg_replace ("/_user_new_/", "_custom_reg_field_", $key))
|
184 |
+
$_POST[$key] = $value; /* Add these keys for uniformity. */
|
185 |
+
unset ($key, $value); /* Prevents bleeding vars into Hooks/Filters. */
|
186 |
+
/**/
|
187 |
+
if (!is_admin () && ($_POST["ws_plugin__s2member_custom_reg_field_s2member_custom"] || $_POST["ws_plugin__s2member_custom_reg_field_s2member_subscr_id"] || $_POST["ws_plugin__s2member_custom_reg_field_s2member_ccaps"] || $_POST["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"] || $_POST["ws_plugin__s2member_custom_reg_field_s2member_notes"]))
|
188 |
+
exit ("s2Member security violation. You attempted to POST variables that will NOT be trusted!");
|
189 |
+
/**/
|
190 |
+
$_pm = array_merge ((array)$_POST, (array)$meta); /* Merge these two data sources together now. However, ALWAYS after the security routine above ^. */
|
191 |
+
/**/
|
192 |
+
if (!is_admin () /* Only run this particular routine whenever a Member [1-4] is registering themselves with cookies. */
|
193 |
+
&& ($subscr_id = ws_plugin__s2member_decrypt ($_COOKIE["s2member_subscr_id"])) && preg_match ("/^" . preg_quote (preg_replace ("/\:([0-9]+)$/", "", $_SERVER["HTTP_HOST"]), "/") . "/i", ($custom = ws_plugin__s2member_decrypt ($_COOKIE["s2member_custom"]))) && preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", ($level = ws_plugin__s2member_decrypt ($_COOKIE["s2member_level"])))/**/
|
194 |
+
&& (!$usermeta = $wpdb->get_row ("SELECT `user_id` FROM `" . $wpdb->usermeta . "` WHERE `meta_key` = '" . $wpdb->prefix . "s2member_subscr_id' AND `meta_value` = '" . $wpdb->escape ($subscr_id) . "' LIMIT 1")))
|
195 |
+
/* ^ This is for security ^ It checks the database to make sure the User/Member has not already registered in the past, with the same Paid Subscr. ID. */
|
196 |
+
{ /*
|
197 |
+
This routine could be processed through `wp-login.php?action=register` - OR - through `wp-activate.php`.
|
198 |
+
If processed through `wp-activate.php`, it could've originated inside the admin, via `user-new.php`.
|
199 |
+
This may also be processed through BuddyPress, or another plugin calling `user_register`.
|
200 |
+
*/
|
201 |
+
$processed = "yes"; /* Mark this as yes, to indicate that a routine was processed. */
|
202 |
+
/**/
|
203 |
+
list ($level, $ccaps, $eotper) = preg_split ("/\:/", $level, 3);
|
204 |
+
$role = "s2member_level" . $level; /* Level 1-4. */
|
205 |
+
/**/
|
206 |
+
$email = $user->user_email;
|
207 |
+
$login = $user->user_login;
|
208 |
+
$ip = $_SERVER["REMOTE_ADDR"];
|
209 |
+
$cv = preg_split ("/\|/", $custom);
|
210 |
+
/**/
|
211 |
+
if ($eotper) /* If a specific EOT Period has been attached; we need to calculate that now. */
|
212 |
+
$auto_eot_time = ws_plugin__s2member_paypal_auto_eot_time (0, 0, 0, $eotper);
|
213 |
+
/**/
|
214 |
+
$notes = $_pm["ws_plugin__s2member_custom_reg_field_s2member_notes"];
|
215 |
+
/**/
|
216 |
+
$opt_in = (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"]) ? true : false;
|
217 |
+
$opt_in = (!$opt_in && $_pm["ws_plugin__s2member_custom_reg_field_opt_in"]) ? true : $opt_in;
|
218 |
+
/**/
|
219 |
+
if (! ($fname = $user->first_name))
|
220 |
+
if ($_pm["ws_plugin__s2member_custom_reg_field_first_name"])
|
221 |
+
$fname = $_pm["ws_plugin__s2member_custom_reg_field_first_name"];
|
222 |
+
/**/
|
223 |
+
if (!$fname) /* Also try BuddyPress. */
|
224 |
+
if ($_pm["field_1"]) /* BuddyPress. */
|
225 |
+
$fname = trim (preg_replace ("/ (.*)$/", "", $_pm["field_1"]));
|
226 |
+
/**/
|
227 |
+
if (! ($lname = $user->last_name))
|
228 |
+
if ($_pm["ws_plugin__s2member_custom_reg_field_last_name"])
|
229 |
+
$lname = $_pm["ws_plugin__s2member_custom_reg_field_last_name"];
|
230 |
+
/**/
|
231 |
+
if (!$lname) /* Also try BuddyPress. */
|
232 |
+
if ($_pm["field_1"] && preg_match ("/^(.+?) (.+)$/", $_pm["field_1"]))
|
233 |
+
$lname = trim (preg_replace ("/^(.+?) (.+)$/", "$2", $_pm["field_1"]));
|
234 |
+
/**/
|
235 |
+
$name = trim ($fname . " " . $lname); /* Both names. */
|
236 |
+
/**/
|
237 |
+
if (! ($pass = $password)) /* Try s2Member's generator. */
|
238 |
+
if ($GLOBALS["ws_plugin__s2member_generate_password_return"])
|
239 |
+
$pass = $GLOBALS["ws_plugin__s2member_generate_password_return"];
|
240 |
+
/**/
|
241 |
+
if (!$pass) /* Also try BuddyPress password. */
|
242 |
+
if ($_pm["signup_password"]) /* BuddyPress. */
|
243 |
+
$pass = $_pm["signup_password"];
|
244 |
+
/**/
|
245 |
+
if ($pass) /* No password nag. Update this globally. */
|
246 |
+
{
|
247 |
+
delete_user_setting ("default_password_nag"); /* setcookie() */
|
248 |
+
update_user_option ($user_id, "default_password_nag", false, true);
|
249 |
+
}
|
250 |
+
/**/
|
251 |
+
update_user_option ($user_id, "s2member_auto_eot_time", $auto_eot_time);
|
252 |
+
update_user_option ($user_id, "s2member_subscr_id", $subscr_id);
|
253 |
+
update_user_option ($user_id, "s2member_custom", $custom);
|
254 |
+
update_user_option ($user_id, "s2member_notes", $notes);
|
255 |
+
/**/
|
256 |
+
if (!$user->first_name && $fname)
|
257 |
+
update_user_meta ($user_id, "first_name", $fname) ./**/
|
258 |
+
wp_update_user (array ("ID" => $user_id, "display_name" => $fname));
|
259 |
+
/**/
|
260 |
+
if (!$user->last_name && $lname)
|
261 |
+
update_user_meta ($user_id, "last_name", $lname);
|
262 |
+
/**/
|
263 |
+
if (is_multisite ()) /* Originating Blog ID#, and adjust Main Site permissions. */
|
264 |
+
{
|
265 |
+
(!is_main_site ()) ? remove_user_from_blog ($user_id, $current_site->blog_id) : null;
|
266 |
+
update_user_meta ($user_id, "s2member_originating_blog", $current_blog->blog_id);
|
267 |
+
}
|
268 |
+
/**/
|
269 |
+
$user->set_role ($role); /* s2Member. */
|
270 |
+
/**/
|
271 |
+
if ($ccaps) /* Add Custom Capabilities. */
|
272 |
+
foreach (preg_split ("/[\r\n\t\s;,]+/", $ccaps) as $ccap)
|
273 |
+
if (strlen ($ccap)) /* Don't add empty capabilities. */
|
274 |
+
$user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
|
275 |
+
/**/
|
276 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
277 |
+
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
278 |
+
{
|
279 |
+
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
280 |
+
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
281 |
+
/**/
|
282 |
+
if (isset ($_pm["ws_plugin__s2member_custom_reg_field_" . $field_var]))
|
283 |
+
$fields[$field_var] = $_pm["ws_plugin__s2member_custom_reg_field_" . $field_var];
|
284 |
+
}
|
285 |
+
/**/
|
286 |
+
update_user_option ($user_id, "s2member_custom_fields", $fields);
|
287 |
+
/**/
|
288 |
+
if (($transient = md5 ("s2member_transient_ipn_subscr_payment_" . $subscr_id)) && is_array ($subscr_payment = get_transient ($transient)))
|
289 |
+
{
|
290 |
+
$proxy = array ("s2member_paypal_notify" => "1", "s2member_paypal_proxy" => "s2member_transient_ipn_subscr_payment");
|
291 |
+
ws_plugin__s2member_remote (add_query_arg ($proxy, get_bloginfo ("wpurl")), stripslashes_deep ($subscr_payment), array ("timeout" => 20));
|
292 |
+
delete_transient($transient);
|
293 |
+
}
|
294 |
+
/**/
|
295 |
+
setcookie ("s2member_signup_tracking", ws_plugin__s2member_encrypt ($subscr_id), time () + 31556926, "/");
|
296 |
+
/**/
|
297 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
298 |
+
do_action ("ws_plugin__s2member_during_configure_user_registration_front_side", get_defined_vars ());
|
299 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
300 |
+
}
|
301 |
+
/**/
|
302 |
+
else if (!is_admin ()) /* Otherwise, if we are NOT inside the Dashboard during the creation of this account. */
|
303 |
+
{ /*
|
304 |
+
This routine could be processed through `wp-login.php?action=register` - OR - through `wp-activate.php`.
|
305 |
+
If processed through `wp-activate.php`, it could've originated inside the admin, via `user-new.php`.
|
306 |
+
This may also be processed through BuddyPress, or another plugin calling `user_register`.
|
307 |
+
*/
|
308 |
+
$processed = "yes"; /* Mark this as yes, to indicate that a routine was processed. */
|
309 |
+
/**/
|
310 |
+
$role = $role = $user->roles[0]; /* If they already have a Role, we can use it. */
|
311 |
+
$role = (!$role && is_multisite () && is_main_site ()) ? get_site_option ("default_user_role") : $role;
|
312 |
+
$role = (!$role) ? get_option ("default_role") : $role; /* Otherwise, the default role. */
|
313 |
+
/**/
|
314 |
+
$level = (preg_match ("/^(administrator|editor|author|contributor)$/i", $role)) ? "4" : $level;
|
315 |
+
$level = (!$level && preg_match ("/^s2member_level[1-4]$/i", $role)) ? preg_replace ("/^s2member_level/", "", $role) : $level;
|
316 |
+
$level = (!$level && preg_match ("/^subscriber$/i", $role)) ? "0" : $level;
|
317 |
+
$level = (!$level) ? "0" : $level;
|
318 |
+
/**/
|
319 |
+
$ccaps = $_pm["ws_plugin__s2member_custom_reg_field_s2member_ccaps"];
|
320 |
+
/**/
|
321 |
+
$email = $user->user_email;
|
322 |
+
$login = $user->user_login;
|
323 |
+
$ip = $_SERVER["REMOTE_ADDR"];
|
324 |
+
$custom = $_pm["ws_plugin__s2member_custom_reg_field_s2member_custom"];
|
325 |
+
$subscr_id = $_pm["ws_plugin__s2member_custom_reg_field_s2member_subscr_id"];
|
326 |
+
$cv = preg_split ("/\|/", $_pm["ws_plugin__s2member_custom_reg_field_s2member_custom"]);
|
327 |
+
/**/
|
328 |
+
$auto_eot_time = ($eot = $_pm["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"]) ? strtotime ($eot) : "";
|
329 |
+
$notes = $_pm["ws_plugin__s2member_custom_reg_field_s2member_notes"];
|
330 |
+
/**/
|
331 |
+
$opt_in = (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"]) ? true : false;
|
332 |
+
$opt_in = (!$opt_in && $_pm["ws_plugin__s2member_custom_reg_field_opt_in"]) ? true : $opt_in;
|
333 |
+
/**/
|
334 |
+
if (! ($fname = $user->first_name))
|
335 |
+
if ($_pm["ws_plugin__s2member_custom_reg_field_first_name"])
|
336 |
+
$fname = $_pm["ws_plugin__s2member_custom_reg_field_first_name"];
|
337 |
+
/**/
|
338 |
+
if (!$fname) /* Also try BuddyPress. */
|
339 |
+
if ($_pm["field_1"]) /* BuddyPress. */
|
340 |
+
$fname = trim (preg_replace ("/ (.*)$/", "", $_pm["field_1"]));
|
341 |
+
/**/
|
342 |
+
if (! ($lname = $user->last_name))
|
343 |
+
if ($_pm["ws_plugin__s2member_custom_reg_field_last_name"])
|
344 |
+
$lname = $_pm["ws_plugin__s2member_custom_reg_field_last_name"];
|
345 |
+
/**/
|
346 |
+
if (!$lname) /* Also try BuddyPress. */
|
347 |
+
if ($_pm["field_1"] && preg_match ("/^(.+?) (.+)$/", $_pm["field_1"]))
|
348 |
+
$lname = trim (preg_replace ("/^(.+?) (.+)$/", "$2", $_pm["field_1"]));
|
349 |
+
/**/
|
350 |
+
$name = trim ($fname . " " . $lname); /* Both names. */
|
351 |
+
/**/
|
352 |
+
if (! ($pass = $password)) /* Try s2Member's generator. */
|
353 |
+
if ($GLOBALS["ws_plugin__s2member_generate_password_return"])
|
354 |
+
$pass = $GLOBALS["ws_plugin__s2member_generate_password_return"];
|
355 |
+
/**/
|
356 |
+
if (!$pass) /* Also try BuddyPress password. */
|
357 |
+
if ($_pm["signup_password"]) /* BuddyPress. */
|
358 |
+
$pass = $_pm["signup_password"];
|
359 |
+
/**/
|
360 |
+
if ($pass) /* No password nag. Update this globally. */
|
361 |
+
{
|
362 |
+
delete_user_setting ("default_password_nag"); /* setcookie() */
|
363 |
+
update_user_option ($user_id, "default_password_nag", false, true);
|
364 |
+
}
|
365 |
+
/**/
|
366 |
+
update_user_option ($user_id, "s2member_auto_eot_time", $auto_eot_time);
|
367 |
+
update_user_option ($user_id, "s2member_subscr_id", $subscr_id);
|
368 |
+
update_user_option ($user_id, "s2member_custom", $custom);
|
369 |
+
update_user_option ($user_id, "s2member_notes", $notes);
|
370 |
+
/**/
|
371 |
+
if (!$user->first_name && $fname)
|
372 |
+
update_user_meta ($user_id, "first_name", $fname) ./**/
|
373 |
+
wp_update_user (array ("ID" => $user_id, "display_name" => $fname));
|
374 |
+
/**/
|
375 |
+
if (!$user->last_name && $lname)
|
376 |
+
update_user_meta ($user_id, "last_name", $lname);
|
377 |
+
/**/
|
378 |
+
if (is_multisite ()) /* Originating Blog ID#, and adjust Main Site permissions. */
|
379 |
+
{
|
380 |
+
(!is_main_site ()) ? remove_user_from_blog ($user_id, $current_site->blog_id) : null;
|
381 |
+
update_user_meta ($user_id, "s2member_originating_blog", $current_blog->blog_id);
|
382 |
+
}
|
383 |
+
/**/
|
384 |
+
$user->set_role ($role); /* s2Member. */
|
385 |
+
/**/
|
386 |
+
if ($ccaps) /* Add Custom Capabilities. */
|
387 |
+
foreach (preg_split ("/[\r\n\t\s;,]+/", $ccaps) as $ccap)
|
388 |
+
if (strlen ($ccap)) /* Don't add empty capabilities. */
|
389 |
+
$user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
|
390 |
+
/**/
|
391 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
392 |
+
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
393 |
+
{
|
394 |
+
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
395 |
+
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
396 |
+
/**/
|
397 |
+
if (isset ($_pm["ws_plugin__s2member_custom_reg_field_" . $field_var]))
|
398 |
+
$fields[$field_var] = $_pm["ws_plugin__s2member_custom_reg_field_" . $field_var];
|
399 |
+
}
|
400 |
+
/**/
|
401 |
+
update_user_option ($user_id, "s2member_custom_fields", $fields);
|
402 |
+
/**/
|
403 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
404 |
+
do_action ("ws_plugin__s2member_during_configure_user_registration_front_side", get_defined_vars ());
|
405 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
406 |
+
}
|
407 |
+
/**/
|
408 |
+
else if (is_admin () && $pagenow === "user-new.php") /* Else, if we're on this page. */
|
409 |
+
{ /*
|
410 |
+
This routine can ONLY be processed through `user-new.php` inside the Dashboard.
|
411 |
+
*/
|
412 |
+
$processed = "yes"; /* Mark this as yes, to indicate that a routine was processed. */
|
413 |
+
/**/
|
414 |
+
$role = $role = $user->roles[0]; /* If they already have a Role, we can use it. */
|
415 |
+
$role = (!$role && is_multisite () && is_main_site ()) ? get_site_option ("default_user_role") : $role;
|
416 |
+
$role = (!$role) ? get_option ("default_role") : $role; /* Otherwise, the default role. */
|
417 |
+
/**/
|
418 |
+
$level = (preg_match ("/^(administrator|editor|author|contributor)$/i", $role)) ? "4" : $level;
|
419 |
+
$level = (!$level && preg_match ("/^s2member_level[1-4]$/i", $role)) ? preg_replace ("/^s2member_level/", "", $role) : $level;
|
420 |
+
$level = (!$level && preg_match ("/^subscriber$/i", $role)) ? "0" : $level;
|
421 |
+
$level = (!$level) ? "0" : $level;
|
422 |
+
/**/
|
423 |
+
$ccaps = $_pm["ws_plugin__s2member_custom_reg_field_s2member_ccaps"];
|
424 |
+
/**/
|
425 |
+
$email = $user->user_email;
|
426 |
+
$login = $user->user_login;
|
427 |
+
$ip = ""; /* N/Applicable. */
|
428 |
+
$custom = $_pm["ws_plugin__s2member_custom_reg_field_s2member_custom"];
|
429 |
+
$subscr_id = $_pm["ws_plugin__s2member_custom_reg_field_s2member_subscr_id"];
|
430 |
+
$cv = preg_split ("/\|/", $_pm["ws_plugin__s2member_custom_reg_field_s2member_custom"]);
|
431 |
+
/**/
|
432 |
+
$auto_eot_time = ($eot = $_pm["ws_plugin__s2member_custom_reg_field_s2member_auto_eot_time"]) ? strtotime ($eot) : "";
|
433 |
+
$notes = $_pm["ws_plugin__s2member_custom_reg_field_s2member_notes"];
|
434 |
+
/**/
|
435 |
+
$opt_in = (!$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"]) ? true : false;
|
436 |
+
$opt_in = (!$opt_in && $_pm["ws_plugin__s2member_custom_reg_field_opt_in"]) ? true : $opt_in;
|
437 |
+
/**/
|
438 |
+
if (! ($fname = $user->first_name)) /* `Users -> Add New`. */
|
439 |
+
if ($_pm["ws_plugin__s2member_custom_reg_field_first_name"])
|
440 |
+
$fname = $_pm["ws_plugin__s2member_custom_reg_field_first_name"];
|
441 |
+
/**/
|
442 |
+
if (! ($lname = $user->last_name)) /* `Users -> Add New`. */
|
443 |
+
if ($_pm["ws_plugin__s2member_custom_reg_field_last_name"])
|
444 |
+
$lname = $_pm["ws_plugin__s2member_custom_reg_field_last_name"];
|
445 |
+
/**/
|
446 |
+
$name = trim ($fname . " " . $lname); /* Both names. */
|
447 |
+
/**/
|
448 |
+
if (! ($pass = $password)) /* Try s2Member's generator. */
|
449 |
+
if ($GLOBALS["ws_plugin__s2member_generate_password_return"])
|
450 |
+
$pass = $GLOBALS["ws_plugin__s2member_generate_password_return"];
|
451 |
+
/**/
|
452 |
+
if (!$pass) /* Also try the `Users -> Add New` form. */
|
453 |
+
if ($_pm["pass1"]) /* Field in user-new.php. */
|
454 |
+
$pass = $_pm["pass1"];
|
455 |
+
/**/
|
456 |
+
if ($pass) /* No password nag. Update this globally. */
|
457 |
+
{
|
458 |
+
delete_user_setting ("default_password_nag"); /* setcookie() */
|
459 |
+
update_user_option ($user_id, "default_password_nag", false, true);
|
460 |
+
}
|
461 |
+
/**/
|
462 |
+
update_user_option ($user_id, "s2member_auto_eot_time", $auto_eot_time);
|
463 |
+
update_user_option ($user_id, "s2member_subscr_id", $subscr_id);
|
464 |
+
update_user_option ($user_id, "s2member_custom", $custom);
|
465 |
+
update_user_option ($user_id, "s2member_notes", $notes);
|
466 |
+
/**/
|
467 |
+
if (!$user->first_name && $fname)
|
468 |
+
update_user_meta ($user_id, "first_name", $fname) ./**/
|
469 |
+
wp_update_user (array ("ID" => $user_id, "display_name" => $fname));
|
470 |
+
/**/
|
471 |
+
if (!$user->last_name && $lname)
|
472 |
+
update_user_meta ($user_id, "last_name", $lname);
|
473 |
+
/**/
|
474 |
+
if (is_multisite ()) /* Originating Blog ID#, and adjust Main Site permissions. */
|
475 |
+
{
|
476 |
+
(!is_main_site ()) ? remove_user_from_blog ($user_id, $current_site->blog_id) : null;
|
477 |
+
update_user_meta ($user_id, "s2member_originating_blog", $current_blog->blog_id);
|
478 |
+
}
|
479 |
+
/**/
|
480 |
+
$user->set_role ($role); /* s2Member. */
|
481 |
+
/**/
|
482 |
+
foreach (preg_split ("/[\r\n\t\s;,]+/", $ccaps) as $ccap)
|
483 |
+
if (strlen ($ccap)) /* Don't add empty capabilities. */
|
484 |
+
$user->add_cap ("access_s2member_ccap_" . trim (strtolower ($ccap)));
|
485 |
+
/**/
|
486 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
487 |
+
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
488 |
+
{
|
489 |
+
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
490 |
+
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
491 |
+
/**/
|
492 |
+
if (isset ($_pm["ws_plugin__s2member_custom_reg_field_" . $field_var]))
|
493 |
+
$fields[$field_var] = $_pm["ws_plugin__s2member_custom_reg_field_" . $field_var];
|
494 |
+
}
|
495 |
+
/**/
|
496 |
+
update_user_option ($user_id, "s2member_custom_fields", $fields);
|
497 |
+
/**/
|
498 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
499 |
+
do_action ("ws_plugin__s2member_during_configure_user_registration_admin_side", get_defined_vars ());
|
500 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
501 |
+
}
|
502 |
+
/**/
|
503 |
+
if ($processed === "yes") /* If registration was processed by one of the routines above. */
|
504 |
+
{
|
505 |
+
ws_plugin__s2member_process_list_servers ($level, $email, $fname, $lname, $ip, $opt_in);
|
506 |
+
/**/
|
507 |
+
if ($urls = $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_urls"])
|
508 |
+
/**/
|
509 |
+
foreach (preg_split ("/[\r\n\t]+/", $urls) as $url) /* Notify each of the urls. */
|
510 |
+
/**/
|
511 |
+
if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)))
|
512 |
+
if (($url = preg_replace ("/%%role%%/i", ws_plugin__s2member_esc_ds (urlencode ($role)), $url)))
|
513 |
+
if (($url = preg_replace ("/%%level%%/i", ws_plugin__s2member_esc_ds (urlencode ($level)), $url)))
|
514 |
+
if (($url = preg_replace ("/%%user_first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($fname)), $url)))
|
515 |
+
if (($url = preg_replace ("/%%user_last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($lname)), $url)))
|
516 |
+
if (($url = preg_replace ("/%%user_full_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($name)), $url)))
|
517 |
+
if (($url = preg_replace ("/%%user_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($email)), $url)))
|
518 |
+
if (($url = preg_replace ("/%%user_login%%/i", ws_plugin__s2member_esc_ds (urlencode ($login)), $url)))
|
519 |
+
if (($url = preg_replace ("/%%user_pass%%/i", ws_plugin__s2member_esc_ds (urlencode ($pass)), $url)))
|
520 |
+
if (($url = preg_replace ("/%%user_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($user_id)), $url)))
|
521 |
+
/**/
|
522 |
+
if (($url = trim ($url))) /* Empty? */
|
523 |
+
ws_plugin__s2member_remote($url);
|
524 |
+
/**/
|
525 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_recipients"])
|
526 |
+
{
|
527 |
+
$msg = $sbj = "( s2Member / API Notification Email ) - Registration";
|
528 |
+
$msg .= "\n\n"; /* Spacing in the message body. */
|
529 |
+
$msg .= "role: %%role%%\n";
|
530 |
+
$msg .= "level: %%level%%\n";
|
531 |
+
$msg .= "user_first_name: %%user_first_name%%\n";
|
532 |
+
$msg .= "user_last_name: %%user_last_name%%\n";
|
533 |
+
$msg .= "user_full_name: %%user_full_name%%\n";
|
534 |
+
$msg .= "user_email: %%user_email%%\n";
|
535 |
+
$msg .= "user_login: %%user_login%%\n";
|
536 |
+
$msg .= "user_pass: %%user_pass%%\n";
|
537 |
+
$msg .= "user_id: %%user_id%%\n";
|
538 |
+
$msg .= "cv0: %%cv0%%\n";
|
539 |
+
$msg .= "cv1: %%cv1%%\n";
|
540 |
+
$msg .= "cv2: %%cv2%%\n";
|
541 |
+
$msg .= "cv3: %%cv3%%\n";
|
542 |
+
$msg .= "cv4: %%cv4%%\n";
|
543 |
+
$msg .= "cv5: %%cv5%%\n";
|
544 |
+
$msg .= "cv6: %%cv6%%\n";
|
545 |
+
$msg .= "cv7: %%cv7%%\n";
|
546 |
+
$msg .= "cv8: %%cv8%%\n";
|
547 |
+
$msg .= "cv9: %%cv9%%";
|
548 |
+
/**/
|
549 |
+
if (($msg = preg_replace ("/%%cv([0-9]+)%%/ei", 'trim($cv[$1])', $msg)))
|
550 |
+
if (($msg = preg_replace ("/%%role%%/i", ws_plugin__s2member_esc_ds ($role), $msg)))
|
551 |
+
if (($msg = preg_replace ("/%%level%%/i", ws_plugin__s2member_esc_ds ($level), $msg)))
|
552 |
+
if (($msg = preg_replace ("/%%user_first_name%%/i", ws_plugin__s2member_esc_ds ($fname), $msg)))
|
553 |
+
if (($msg = preg_replace ("/%%user_last_name%%/i", ws_plugin__s2member_esc_ds ($lname), $msg)))
|
554 |
+
if (($msg = preg_replace ("/%%user_full_name%%/i", ws_plugin__s2member_esc_ds ($name), $msg)))
|
555 |
+
if (($msg = preg_replace ("/%%user_email%%/i", ws_plugin__s2member_esc_ds ($email), $msg)))
|
556 |
+
if (($msg = preg_replace ("/%%user_login%%/i", ws_plugin__s2member_esc_ds ($login), $msg)))
|
557 |
+
if (($msg = preg_replace ("/%%user_pass%%/i", ws_plugin__s2member_esc_ds ($pass), $msg)))
|
558 |
+
if (($msg = preg_replace ("/%%user_id%%/i", ws_plugin__s2member_esc_ds ($user_id), $msg)))
|
559 |
+
/**/
|
560 |
+
foreach (ws_plugin__s2member_trim_deep (preg_split ("/;+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["registration_notification_recipients"])) as $recipient)
|
561 |
+
/**/
|
562 |
+
($recipient) ? mail ($recipient, $sbj, apply_filters ("ws_plugin__s2member_registration_notification_email_msg", $msg, get_defined_vars ()), "From: \"" . preg_replace ('/"/', "'", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"]) . "\" <" . $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_email"] . ">\r\nContent-Type: text/plain; charset=utf-8") : null;
|
563 |
+
}
|
564 |
+
/**/
|
565 |
+
if ($url = $GLOBALS["ws_plugin__s2member_registration_return_url"])
|
566 |
+
/**/
|
567 |
+
if (($url = preg_replace ("/%%cv([0-9]+)%%/ei", 'urlencode(trim($cv[$1]))', $url)))
|
568 |
+
if (($url = preg_replace ("/%%role%%/i", ws_plugin__s2member_esc_ds (urlencode ($role)), $url)))
|
569 |
+
if (($url = preg_replace ("/%%level%%/i", ws_plugin__s2member_esc_ds (urlencode ($level)), $url)))
|
570 |
+
if (($url = preg_replace ("/%%user_first_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($fname)), $url)))
|
571 |
+
if (($url = preg_replace ("/%%user_last_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($lname)), $url)))
|
572 |
+
if (($url = preg_replace ("/%%user_full_name%%/i", ws_plugin__s2member_esc_ds (urlencode ($name)), $url)))
|
573 |
+
if (($url = preg_replace ("/%%user_email%%/i", ws_plugin__s2member_esc_ds (urlencode ($email)), $url)))
|
574 |
+
if (($url = preg_replace ("/%%user_login%%/i", ws_plugin__s2member_esc_ds (urlencode ($login)), $url)))
|
575 |
+
if (($url = preg_replace ("/%%user_pass%%/i", ws_plugin__s2member_esc_ds (urlencode ($pass)), $url)))
|
576 |
+
if (($url = preg_replace ("/%%user_id%%/i", ws_plugin__s2member_esc_ds (urlencode ($user_id)), $url)))
|
577 |
+
/**/
|
578 |
+
if (($url = trim ($url))) /* Empty? ... Otherwise, re-fill. */
|
579 |
+
$GLOBALS["ws_plugin__s2member_registration_return_url"] = $url;
|
580 |
+
/**/
|
581 |
+
setcookie ("s2member_subscr_id", "", time () + 31556926, "/");
|
582 |
+
setcookie ("s2member_custom", "", time () + 31556926, "/");
|
583 |
+
setcookie ("s2member_level", "", time () + 31556926, "/");
|
584 |
+
/**/
|
585 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
586 |
+
do_action ("ws_plugin__s2member_during_configure_user_registration", get_defined_vars ());
|
587 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
588 |
+
}
|
589 |
+
}
|
590 |
+
/**/
|
591 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
592 |
+
do_action ("ws_plugin__s2member_after_configure_user_registration", get_defined_vars ());
|
593 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
594 |
+
/**/
|
595 |
+
return;
|
596 |
+
}
|
597 |
+
}
|
598 |
+
?>
|
includes/functions/css-js-w-globals.inc.php
CHANGED
@@ -14,8 +14,7 @@ Direct access denial.
|
|
14 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
15 |
exit ("Do not access this file directly.");
|
16 |
/*
|
17 |
-
|
18 |
-
Do NOT enqueue styles in the admin area.
|
19 |
Attach to: add_action("wp_print_styles");
|
20 |
*/
|
21 |
if (!function_exists ("ws_plugin__s2member_add_css"))
|
@@ -37,7 +36,7 @@ if (!function_exists ("ws_plugin__s2member_add_css"))
|
|
37 |
}
|
38 |
}
|
39 |
/*
|
40 |
-
|
41 |
Attach to: add_action("init");
|
42 |
*/
|
43 |
if (!function_exists ("ws_plugin__s2member_css"))
|
@@ -70,19 +69,20 @@ if (!function_exists ("ws_plugin__s2member_css"))
|
|
70 |
}
|
71 |
}
|
72 |
/*
|
73 |
-
|
74 |
-
Do NOT enqueue scripts in the admin area.
|
75 |
Attach to: add_action("wp_print_scripts");
|
76 |
*/
|
77 |
if (!function_exists ("ws_plugin__s2member_add_js_w_globals"))
|
78 |
{
|
79 |
function ws_plugin__s2member_add_js_w_globals ()
|
80 |
{
|
|
|
|
|
81 |
do_action ("ws_plugin__s2member_before_add_js_w_globals", get_defined_vars ());
|
82 |
/**/
|
83 |
-
if (!is_admin ()
|
84 |
{
|
85 |
-
if (is_user_logged_in ())
|
86 |
{
|
87 |
$md5 = WS_PLUGIN__S2MEMBER_API_CONSTANTS_MD5; /* An MD5 hash based on global key => values. */
|
88 |
/* The MD5 hash allows the script to be cached in the browser until the globals happen to change. */
|
@@ -103,7 +103,7 @@ if (!function_exists ("ws_plugin__s2member_add_js_w_globals"))
|
|
103 |
}
|
104 |
}
|
105 |
/*
|
106 |
-
|
107 |
Attach to: add_action("init");
|
108 |
*/
|
109 |
if (!function_exists ("ws_plugin__s2member_js_w_globals"))
|
14 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
15 |
exit ("Do not access this file directly.");
|
16 |
/*
|
17 |
+
Adds CSS files.
|
|
|
18 |
Attach to: add_action("wp_print_styles");
|
19 |
*/
|
20 |
if (!function_exists ("ws_plugin__s2member_add_css"))
|
36 |
}
|
37 |
}
|
38 |
/*
|
39 |
+
Builds CSS files.
|
40 |
Attach to: add_action("init");
|
41 |
*/
|
42 |
if (!function_exists ("ws_plugin__s2member_css"))
|
69 |
}
|
70 |
}
|
71 |
/*
|
72 |
+
Adds JavaScript files.
|
|
|
73 |
Attach to: add_action("wp_print_scripts");
|
74 |
*/
|
75 |
if (!function_exists ("ws_plugin__s2member_add_js_w_globals"))
|
76 |
{
|
77 |
function ws_plugin__s2member_add_js_w_globals ()
|
78 |
{
|
79 |
+
global $pagenow; /* Need this for comparisons. */
|
80 |
+
/**/
|
81 |
do_action ("ws_plugin__s2member_before_add_js_w_globals", get_defined_vars ());
|
82 |
/**/
|
83 |
+
if (!is_admin () || ($pagenow === "profile.php" && !current_user_can ("edit_users")))
|
84 |
{
|
85 |
+
if (is_user_logged_in ()) /* Separate version for logged-in Users/Members. */
|
86 |
{
|
87 |
$md5 = WS_PLUGIN__S2MEMBER_API_CONSTANTS_MD5; /* An MD5 hash based on global key => values. */
|
88 |
/* The MD5 hash allows the script to be cached in the browser until the globals happen to change. */
|
103 |
}
|
104 |
}
|
105 |
/*
|
106 |
+
Builds JavaScript files.
|
107 |
Attach to: add_action("init");
|
108 |
*/
|
109 |
if (!function_exists ("ws_plugin__s2member_js_w_globals"))
|
includes/functions/custom-reg-fields.inc.php
ADDED
@@ -0,0 +1,453 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 ("Do not access this file directly.");
|
16 |
+
/*
|
17 |
+
Handles the creation of Custom Fields.
|
18 |
+
*/
|
19 |
+
if (!function_exists ("ws_plugin__s2member_custom_field_gen"))
|
20 |
+
{
|
21 |
+
function ws_plugin__s2member_custom_field_gen ($_function = FALSE, $_field = FALSE, $_name_prefix = FALSE, $_id_prefix = FALSE, $_classes = FALSE, $_styles = FALSE, $_tabindex = FALSE, $_attrs = FALSE, $_submission = FALSE, $_value = FALSE, $_lock_uneditables = FALSE)
|
22 |
+
{
|
23 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
24 |
+
do_action ("ws_plugin__s2member_before_custom_field_gen", get_defined_vars ());
|
25 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
26 |
+
/**/
|
27 |
+
if ($_function && is_array ($field = $_field) && $field["type"] && $field["id"] && $_name_prefix && $_id_prefix)
|
28 |
+
{
|
29 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
30 |
+
do_action ("ws_plugin__s2member_during_custom_field_gen_before", get_defined_vars ());
|
31 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
32 |
+
/**/
|
33 |
+
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
34 |
+
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
35 |
+
/**/
|
36 |
+
$name_suffix = (preg_match ("/\[$/", $_name_prefix)) ? ']' : '';
|
37 |
+
$field_name = trim ($_name_prefix . $field_var . $name_suffix);
|
38 |
+
/**/
|
39 |
+
$common = ''; /* Common attribute configuration. */
|
40 |
+
$common .= ' name="' . esc_attr ($field_name) . '"';
|
41 |
+
$common .= ' id="' . esc_attr ($_id_prefix . $field_id_class) . '"';
|
42 |
+
$common .= ( ($field["required"] === "yes") ? ' aria-required="true"' : '');
|
43 |
+
$common .= ( (strlen ($_tabindex)) ? ' tabindex="' . esc_attr ($_tabindex) . '"' : '');
|
44 |
+
$common .= ( ($field["expected"]) ? ' data-expected="' . esc_attr ($field["expected"]) . '"' : '');
|
45 |
+
$common .= ( (preg_match ("/^no/", $field["editable"]) && $_lock_uneditables) ? ' disabled="disabled"' : '');
|
46 |
+
$common .= ( ($_classes || $field["classes"]) ? ' class="' . esc_attr (trim ($_classes . ( ($field["classes"]) ? ' ' . $field["classes"] : ''))) . '"' : '');
|
47 |
+
$common .= ( ($_styles || $field["styles"]) ? ' style="' . esc_attr (trim ($_styles . ( ($field["styles"]) ? ' ' . $field["styles"] : ''))) . '"' : '');
|
48 |
+
$common .= ( ($_attrs || $field["attrs"]) ? ' ' . trim ($_attrs . ( ($field["attrs"]) ? ' ' . $field["attrs"] : '')) : '');
|
49 |
+
/**/
|
50 |
+
if ($field["type"] === "text")
|
51 |
+
{
|
52 |
+
$gen = '<input type="text" maxlength="100"';
|
53 |
+
$gen .= ' value="' . format_to_edit ((string)$_value) . '"';
|
54 |
+
$gen .= $common . ' />';
|
55 |
+
}
|
56 |
+
/**/
|
57 |
+
else if ($field["type"] === "textarea")
|
58 |
+
{
|
59 |
+
$gen = '<textarea rows="3"' . $common . '>';
|
60 |
+
$gen .= format_to_edit ((string)$_value);
|
61 |
+
$gen .= '</textarea>';
|
62 |
+
}
|
63 |
+
/**/
|
64 |
+
else if ($field["type"] === "select" && $field["options"])
|
65 |
+
{
|
66 |
+
$gen = '<select' . $common . '>';
|
67 |
+
foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $option_line)
|
68 |
+
{
|
69 |
+
list ($option_value, $option_label, $option_default) = ws_plugin__s2member_trim_deep (preg_split ("/\|/", trim ($option_line)));
|
70 |
+
$gen .= '<option value="' . esc_attr ($option_value) . '"' . ( ( ($option_default && !$_submission) || $option_value === (string)$_value) ? ' selected="selected"' : '') . '>' . $option_label . '</option>';
|
71 |
+
}
|
72 |
+
$gen .= '</select>';
|
73 |
+
}
|
74 |
+
/**/
|
75 |
+
else if ($field["type"] === "selects" && $field["options"])
|
76 |
+
{
|
77 |
+
$common = preg_replace ('/ name\="(.+?)"/', ' name="$1[]"', $common);
|
78 |
+
$common = preg_replace ('/ style\="(.+?)"/', ' style="height:auto; $1"', $common);
|
79 |
+
/**/
|
80 |
+
$gen = '<select multiple="multiple" size="3"' . $common . '>';
|
81 |
+
foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $option_line)
|
82 |
+
{
|
83 |
+
list ($option_value, $option_label, $option_default) = ws_plugin__s2member_trim_deep (preg_split ("/\|/", trim ($option_line)));
|
84 |
+
$gen .= '<option value="' . esc_attr ($option_value) . '"' . ( ( ($option_default && !$_submission) || in_array ($option_value, (array)$_value)) ? ' selected="selected"' : '') . '>' . $option_label . '</option>';
|
85 |
+
}
|
86 |
+
$gen .= '</select>';
|
87 |
+
}
|
88 |
+
/**/
|
89 |
+
else if ($field["type"] === "checkbox")
|
90 |
+
{
|
91 |
+
$gen = '<input type="checkbox" value="1"';
|
92 |
+
$gen .= ( ((string)$_value) ? ' checked="checked"' : '');
|
93 |
+
$gen .= $common . ' /><label for="' . esc_attr ($_id_prefix . $field_id_class) . '" style="display:inline;">' . $field["label"] . '</label>';
|
94 |
+
}
|
95 |
+
/**/
|
96 |
+
else if ($field["type"] === "pre_checkbox")
|
97 |
+
{
|
98 |
+
$gen = '<input type="checkbox" value="1"';
|
99 |
+
$gen .= ( (!$_submission || (string)$_value) ? ' checked="checked"' : '');
|
100 |
+
$gen .= $common . ' /><label for="' . esc_attr ($_id_prefix . $field_id_class) . '" style="display:inline;">' . $field["label"] . '</label>';
|
101 |
+
}
|
102 |
+
/**/
|
103 |
+
else if ($field["type"] === "checkboxes" && $field["options"])
|
104 |
+
{
|
105 |
+
$gen = ""; /* Initialize generated field. */
|
106 |
+
/**/
|
107 |
+
$common = preg_replace ('/ name\="(.+?)"/', ' name="$1[]"', $common);
|
108 |
+
/**/
|
109 |
+
$sep = apply_filters ("ws_plugin__s2member_custom_field_gen_" . $field["type"] . "_sep", " ", get_defined_vars ());
|
110 |
+
$opl = apply_filters ("ws_plugin__s2member_custom_field_gen_" . $field["type"] . "_opl", "ws-plugin--s2member-custom-reg-field-op-l", get_defined_vars ());
|
111 |
+
/**/
|
112 |
+
foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $i => $option_line)
|
113 |
+
{
|
114 |
+
$common_i = preg_replace ('/ id\="(.+?)"/', ' id="$1-' . ($i) . '"', $common);
|
115 |
+
/**/
|
116 |
+
list ($option_value, $option_label, $option_default) = ws_plugin__s2member_trim_deep (preg_split ("/\|/", trim ($option_line)));
|
117 |
+
/**/
|
118 |
+
$gen .= ($i > 0) ? $sep : ''; /* Separators can be filtered above. */
|
119 |
+
$gen .= '<input type="checkbox" value="' . esc_attr ($option_value) . '"';
|
120 |
+
$gen .= ( ( ($option_default && !$_submission) || in_array ($option_value, (array)$_value)) ? ' checked="checked"' : '');
|
121 |
+
$gen .= $common_i . ' /><label for="' . esc_attr ($_id_prefix . $field_id_class . "-" . $i) . '" class="' . esc_attr ($opl) . '" style="display:inline;">' . $option_label . '</label>';
|
122 |
+
}
|
123 |
+
}
|
124 |
+
/**/
|
125 |
+
else if ($field["type"] === "radios" && $field["options"])
|
126 |
+
{
|
127 |
+
$gen = ""; /* Initialize generated field. */
|
128 |
+
/**/
|
129 |
+
$sep = apply_filters ("ws_plugin__s2member_custom_field_gen_" . $field["type"] . "_sep", " ", get_defined_vars ());
|
130 |
+
$opl = apply_filters ("ws_plugin__s2member_custom_field_gen_" . $field["type"] . "_opl", "ws-plugin--s2member-custom-reg-field-op-l", get_defined_vars ());
|
131 |
+
/**/
|
132 |
+
foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $i => $option_line)
|
133 |
+
{
|
134 |
+
$common_i = preg_replace ('/ id\="(.+?)"/', ' id="$1-' . ($i) . '"', $common);
|
135 |
+
/**/
|
136 |
+
list ($option_value, $option_label, $option_default) = ws_plugin__s2member_trim_deep (preg_split ("/\|/", trim ($option_line)));
|
137 |
+
/**/
|
138 |
+
$gen .= ($i > 0) ? $sep : ''; /* Separators can be filtered above. */
|
139 |
+
$gen .= '<input type="radio" value="' . esc_attr ($option_value) . '"';
|
140 |
+
$gen .= ( ( ($option_default && !$_submission) || $option_value === (string)$_value) ? ' checked="checked"' : '');
|
141 |
+
$gen .= $common_i . ' /><label for="' . esc_attr ($_id_prefix . $field_id_class . "-" . $i) . '" class="' . esc_attr ($opl) . '" style="display:inline;">' . $option_label . '</label>';
|
142 |
+
}
|
143 |
+
}
|
144 |
+
else /* Otherwise, we use a default text field. */
|
145 |
+
{
|
146 |
+
$gen = '<input type="text" maxlength="100"';
|
147 |
+
$gen .= ' value="' . format_to_edit ((string)$_value) . '"';
|
148 |
+
$gen .= $common . ' />';
|
149 |
+
}
|
150 |
+
/**/
|
151 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
152 |
+
do_action ("ws_plugin__s2member_during_custom_field_gen_after", get_defined_vars ());
|
153 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
154 |
+
}
|
155 |
+
/**/
|
156 |
+
return apply_filters ("ws_plugin__s2member_custom_field_gen", $gen, get_defined_vars ());
|
157 |
+
}
|
158 |
+
}
|
159 |
+
/*
|
160 |
+
Function determines whether or not Custom Fields apply to a specific Level.
|
161 |
+
The $level parameter defaults to the current User's Access Level number.
|
162 |
+
$level MUST be numeric >= 0.
|
163 |
+
*/
|
164 |
+
if (!function_exists ("ws_plugin__s2member_custom_fields_configured_at_level"))
|
165 |
+
{
|
166 |
+
function ws_plugin__s2member_custom_fields_configured_at_level ($_level = "auto-detection")
|
167 |
+
{
|
168 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
169 |
+
do_action ("ws_plugin__s2member_before_custom_fields_configured_at_level", get_defined_vars ());
|
170 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
171 |
+
/**/
|
172 |
+
$level = ($_level === "auto-detection") ? ws_plugin__s2member_user_access_level () : $_level;
|
173 |
+
if ($_level === "auto-detection" && $level < 0 && preg_match ("/^[1-4](\:|$)([a-z_0-9,]+)?(\:)?([0-9]+ [A-Z])?$/", ($cookie = ws_plugin__s2member_decrypt ($_COOKIE["s2member_level"]))))
|
174 |
+
list ($level) = preg_split ("/\:/", $cookie, 3);
|
175 |
+
/**/
|
176 |
+
$level = (!is_numeric ($level) || $level < 0) ? 0 : $level; /* Always default to Level #0. */
|
177 |
+
/**/
|
178 |
+
if (is_numeric ($level) && $level >= 0 && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
179 |
+
{
|
180 |
+
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
181 |
+
if ($field["levels"] === "all" || in_array ($level, preg_split ("/[;,]+/", preg_replace ("/[^0-9,]/", "", $field["levels"]))))
|
182 |
+
$configured[] = $field["id"]; /* Add this to the array. */
|
183 |
+
}
|
184 |
+
/**/
|
185 |
+
return apply_filters ("ws_plugin__s2member_custom_fields_configured_at_level", $configured, get_defined_vars ());
|
186 |
+
}
|
187 |
+
}
|
188 |
+
/*
|
189 |
+
This adds custom fields to `wp-signup.php`.
|
190 |
+
Attach to: add_action("signup_extra_fields");
|
191 |
+
~ For Multisite Blog Farms.
|
192 |
+
*/
|
193 |
+
if (!function_exists ("ws_plugin__s2member_ms_custom_registration_fields"))
|
194 |
+
{
|
195 |
+
function ws_plugin__s2member_ms_custom_registration_fields ()
|
196 |
+
{
|
197 |
+
do_action ("ws_plugin__s2member_before_ms_custom_registration_fields", get_defined_vars ());
|
198 |
+
/**/
|
199 |
+
if (is_multisite () && is_main_site ()) /* Must be Multisite / Main Site. */
|
200 |
+
{
|
201 |
+
$_POST = ws_plugin__s2member_trim_deep (stripslashes_deep ($_POST));
|
202 |
+
/**/
|
203 |
+
echo '<input type="hidden" name="ws_plugin__s2member_registration" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-registration")) . '" />' . "\n";
|
204 |
+
/**/
|
205 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
206 |
+
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before", get_defined_vars ());
|
207 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
208 |
+
/**/
|
209 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
210 |
+
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_first_name", get_defined_vars ());
|
211 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
212 |
+
/**/
|
213 |
+
echo '<label for="ws-plugin--s2member-custom-reg-field-first-name">First Name *</label>' . "\n";
|
214 |
+
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" value="' . format_to_edit ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]) . '" />' . "\n";
|
215 |
+
echo '<br />' . "\n";
|
216 |
+
/**/
|
217 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
218 |
+
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_first_name", get_defined_vars ());
|
219 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
220 |
+
/**/
|
221 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
222 |
+
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_last_name", get_defined_vars ());
|
223 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
224 |
+
/**/
|
225 |
+
echo '<label for="ws-plugin--s2member-custom-reg-field-last-name">Last Name *</label>' . "\n";
|
226 |
+
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" value="' . format_to_edit ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]) . '" />' . "\n";
|
227 |
+
echo '<br />' . "\n";
|
228 |
+
/**/
|
229 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
230 |
+
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_last_name", get_defined_vars ());
|
231 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
232 |
+
/**/
|
233 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
234 |
+
if ($fields_applicable = ws_plugin__s2member_custom_fields_configured_at_level ("auto-detection"))
|
235 |
+
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
236 |
+
{
|
237 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
238 |
+
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_custom_fields", get_defined_vars ());
|
239 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
240 |
+
/**/
|
241 |
+
if (in_array ($field["id"], $fields_applicable)) /* Field applicable? */
|
242 |
+
{
|
243 |
+
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
244 |
+
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
245 |
+
/**/
|
246 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
247 |
+
if (apply_filters ("ws_plugin__s2member_during_ms_custom_registration_fields_during_custom_fields_display", true, get_defined_vars ()))
|
248 |
+
{
|
249 |
+
echo '<label for="ws-plugin--s2member-custom-reg-field-' . $field_id_class . '"' . ( (preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '') . '>' . $field["label"] . ( ($field["required"] === "yes") ? ' *' : '') . '</label>' . "\n";
|
250 |
+
echo ws_plugin__s2member_custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_custom_reg_field_", "ws-plugin--s2member-custom-reg-field-", "ws-plugin--s2member-custom-reg-field", "", "", "", $_POST, $_POST["ws_plugin__s2member_custom_reg_field_" . $field_var]);
|
251 |
+
echo '<br />' . "\n";
|
252 |
+
}
|
253 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
254 |
+
}
|
255 |
+
/**/
|
256 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
257 |
+
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_custom_fields", get_defined_vars ());
|
258 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
259 |
+
}
|
260 |
+
/**/
|
261 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && ws_plugin__s2member_list_servers_integrated ())
|
262 |
+
{
|
263 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
264 |
+
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_opt_in", get_defined_vars ());
|
265 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
266 |
+
/**/
|
267 |
+
echo '<label for="ws-plugin--s2member-custom-reg-field-opt-in">' . "\n";
|
268 |
+
echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-opt-in" class="ws-plugin--s2member-custom-reg-field" 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";
|
269 |
+
echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"] . "\n";
|
270 |
+
echo '</label>' . "\n";
|
271 |
+
echo '<br />' . "\n";
|
272 |
+
/**/
|
273 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
274 |
+
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_opt_in", get_defined_vars ());
|
275 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
276 |
+
}
|
277 |
+
/**/
|
278 |
+
echo '<br />' . "\n"; /* Toss in one extra line break ( extra margin ). */
|
279 |
+
/**/
|
280 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
281 |
+
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after", get_defined_vars ());
|
282 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
283 |
+
}
|
284 |
+
/**/
|
285 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
286 |
+
do_action ("ws_plugin__s2member_after_ms_custom_registration_fields", get_defined_vars ());
|
287 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
288 |
+
/**/
|
289 |
+
return; /* Return for uniformity. */
|
290 |
+
}
|
291 |
+
}
|
292 |
+
/*
|
293 |
+
This adds custom fields to `wp-login.php?action=register`.
|
294 |
+
Attach to: add_action("register_form");
|
295 |
+
*/
|
296 |
+
if (!function_exists ("ws_plugin__s2member_custom_registration_fields"))
|
297 |
+
{
|
298 |
+
function ws_plugin__s2member_custom_registration_fields ()
|
299 |
+
{
|
300 |
+
do_action ("ws_plugin__s2member_before_custom_registration_fields", get_defined_vars ());
|
301 |
+
/**/
|
302 |
+
$_POST = ws_plugin__s2member_trim_deep (stripslashes_deep ($_POST));
|
303 |
+
/**/
|
304 |
+
echo '<input type="hidden" name="ws_plugin__s2member_registration" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-registration")) . '" />' . "\n";
|
305 |
+
/**/
|
306 |
+
$tabindex = 20; /* Incremented tabindex starting with 20. */
|
307 |
+
/**/
|
308 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
309 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_before", get_defined_vars ());
|
310 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
311 |
+
/**/
|
312 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"] && function_exists ("ws_plugin__s2member_generate_password"))
|
313 |
+
{
|
314 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
315 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_before_user_pass", get_defined_vars ());
|
316 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
317 |
+
/**/
|
318 |
+
echo '<p>' . "\n";
|
319 |
+
echo '<label>' . "\n";
|
320 |
+
echo '<span>Password *</span><br />' . "\n";
|
321 |
+
echo '<input aria-required="true" type="password" maxlength="100" autocomplete="off" 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" value="' . format_to_edit ($_POST["ws_plugin__s2member_custom_reg_field_user_pass"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
|
322 |
+
echo '</label>' . "\n";
|
323 |
+
echo '</p>';
|
324 |
+
/**/
|
325 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
326 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_after_user_pass", get_defined_vars ());
|
327 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
328 |
+
}
|
329 |
+
/**/
|
330 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
331 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_before_first_name", get_defined_vars ());
|
332 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
333 |
+
/**/
|
334 |
+
echo '<p>' . "\n";
|
335 |
+
echo '<label>' . "\n";
|
336 |
+
echo '<span>First Name *</span><br />' . "\n";
|
337 |
+
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" value="' . format_to_edit ($_POST["ws_plugin__s2member_custom_reg_field_first_name"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
|
338 |
+
echo '</label>' . "\n";
|
339 |
+
echo '</p>';
|
340 |
+
/**/
|
341 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
342 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_after_first_name", get_defined_vars ());
|
343 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
344 |
+
/**/
|
345 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
346 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_before_last_name", get_defined_vars ());
|
347 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
348 |
+
/**/
|
349 |
+
echo '<p>' . "\n";
|
350 |
+
echo '<label>' . "\n";
|
351 |
+
echo '<span>Last Name *</span><br />' . "\n";
|
352 |
+
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" value="' . format_to_edit ($_POST["ws_plugin__s2member_custom_reg_field_last_name"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
|
353 |
+
echo '</label>' . "\n";
|
354 |
+
echo '</p>';
|
355 |
+
/**/
|
356 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
357 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_after_last_name", get_defined_vars ());
|
358 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
359 |
+
/**/
|
360 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])
|
361 |
+
if ($fields_applicable = ws_plugin__s2member_custom_fields_configured_at_level ("auto-detection"))
|
362 |
+
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field)
|
363 |
+
{
|
364 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
365 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_before_custom_fields", get_defined_vars ());
|
366 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
367 |
+
/**/
|
368 |
+
if (in_array ($field["id"], $fields_applicable)) /* Field applicable? */
|
369 |
+
{
|
370 |
+
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"]));
|
371 |
+
$field_id_class = preg_replace ("/_/", "-", $field_var);
|
372 |
+
/**/
|
373 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
374 |
+
if (apply_filters ("ws_plugin__s2member_during_custom_registration_fields_during_custom_fields_display", true, get_defined_vars ()))
|
375 |
+
{
|
376 |
+
echo '<p>' . "\n";
|
377 |
+
echo '<label>' . "\n";
|
378 |
+
echo '<span' . ( (preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '') . '>' . $field["label"] . ( ($field["required"] === "yes") ? ' *' : '') . '</span>' . ( (preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? '' : '<br />') . "\n";
|
379 |
+
echo ws_plugin__s2member_custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_custom_reg_field_", "ws-plugin--s2member-custom-reg-field-", "ws-plugin--s2member-custom-reg-field", "", ($tabindex = $tabindex + 10), "", $_POST, $_POST["ws_plugin__s2member_custom_reg_field_" . $field_var]);
|
380 |
+
echo '</label>' . "\n";
|
381 |
+
echo '</p>';
|
382 |
+
}
|
383 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
384 |
+
}
|
385 |
+
/**/
|
386 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
387 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_after_custom_fields", get_defined_vars ());
|
388 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
389 |
+
}
|
390 |
+
/**/
|
391 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && ws_plugin__s2member_list_servers_integrated ())
|
392 |
+
{
|
393 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
394 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_before_opt_in", get_defined_vars ());
|
395 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
396 |
+
/**/
|
397 |
+
echo '<p>' . "\n";
|
398 |
+
echo '<label>' . "\n";
|
399 |
+
echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-opt-in" class="ws-plugin--s2member-custom-reg-field" 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"' : '') . ' tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n";
|
400 |
+
echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"] . "\n";
|
401 |
+
echo '</label>' . "\n";
|
402 |
+
echo '</p>';
|
403 |
+
/**/
|
404 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
405 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_after_opt_in", get_defined_vars ());
|
406 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
407 |
+
}
|
408 |
+
/**/
|
409 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
410 |
+
do_action ("ws_plugin__s2member_during_custom_registration_fields_after", get_defined_vars ());
|
411 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
412 |
+
/**/
|
413 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
414 |
+
do_action ("ws_plugin__s2member_after_custom_registration_fields", get_defined_vars ());
|
415 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
416 |
+
/**/
|
417 |
+
return;
|
418 |
+
}
|
419 |
+
}
|
420 |
+
/*
|
421 |
+
This adds an opt-in checkbox to the BuddyPress signup form.
|
422 |
+
Attach to: add_action("bp_before_registration_submit_buttons");
|
423 |
+
*/
|
424 |
+
if (!function_exists ("ws_plugin__s2member_opt_in_4bp"))
|
425 |
+
{
|
426 |
+
function ws_plugin__s2member_opt_in_4bp ()
|
427 |
+
{
|
428 |
+
do_action ("ws_plugin__s2member_before_opt_in_4bp", get_defined_vars ());
|
429 |
+
/**/
|
430 |
+
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && ws_plugin__s2member_list_servers_integrated ())
|
431 |
+
{
|
432 |
+
do_action ("ws_plugin__s2member_during_opt_in_4bp_before", get_defined_vars ());
|
433 |
+
/**/
|
434 |
+
echo '<div class="s2member-opt-in-4bp" style="' . apply_filters ("ws_plugin__s2member_opt_in_4bp_styles", "clear:both; padding-top:10px; margin-left:-3px;", get_defined_vars ()) . '">' . "\n";
|
435 |
+
/**/
|
436 |
+
echo '<p>' . "\n";
|
437 |
+
echo '<label>' . "\n";
|
438 |
+
echo '<input type="checkbox" name="ws_plugin__s2member_custom_reg_field_opt_in" id="ws-plugin--s2member-custom-reg-field-opt-in" class="ws-plugin--s2member-custom-reg-field" 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";
|
439 |
+
echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"] . "\n";
|
440 |
+
echo '</label>' . "\n";
|
441 |
+
echo '</p>';
|
442 |
+
/**/
|
443 |
+
echo '</div>' . "\n";
|
444 |
+
/**/
|
445 |
+
do_action ("ws_plugin__s2member_during_opt_in_4bp_after", get_defined_vars ());
|
446 |
+
}
|
447 |
+
/**/
|
448 |
+
do_action ("ws_plugin__s2member_after_opt_in_4bp", get_defined_vars ());
|
449 |
+
/**/
|
450 |
+
return;
|
451 |
+
}
|
452 |
+
}
|
453 |
+
?>
|
includes/functions/demo-users.inc.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 ("Do not access this file directly.");
|
16 |
+
/*
|
17 |
+
Function hides password fields for demo users.
|
18 |
+
|
19 |
+
Demo accounts ( where the Username MUST be "demo" ), will NOT be allowed to change their password.
|
20 |
+
Any other restrictions you need to impose must be done through custom programming, using s2Member's Conditionals.
|
21 |
+
See `s2Member -> API Scripting`.
|
22 |
+
|
23 |
+
Attach to: add_filter("show_password_fields");
|
24 |
+
*/
|
25 |
+
if (!function_exists ("ws_plugin__s2member_demo_hide_password_fields"))
|
26 |
+
{
|
27 |
+
function ws_plugin__s2member_demo_hide_password_fields ($show = TRUE, $profileuser = FALSE)
|
28 |
+
{
|
29 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
30 |
+
do_action ("ws_plugin__s2member_before_demo_hide_password_fields", get_defined_vars ());
|
31 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
32 |
+
/**/
|
33 |
+
if ($profileuser->user_login === "demo")
|
34 |
+
return ($show = false);
|
35 |
+
/**/
|
36 |
+
return $show;
|
37 |
+
}
|
38 |
+
}
|
39 |
+
?>
|
includes/functions/demotions.inc.php
DELETED
@@ -1,29 +0,0 @@
|
|
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 ("Do not access this file directly.");
|
16 |
-
/*
|
17 |
-
Forces a specific Role to demote to; whenever a Member is demoted in one way or another.
|
18 |
-
Use by PayPal® IPN routines, and also by the Auto-EOT system.
|
19 |
-
*/
|
20 |
-
if (!function_exists ("ws_plugin__s2member_force_demotion_role"))
|
21 |
-
{
|
22 |
-
function ws_plugin__s2member_force_demotion_role ($demotion_role = FALSE)
|
23 |
-
{
|
24 |
-
do_action ("ws_plugin__s2member_before_force_demotion_role", get_defined_vars ());
|
25 |
-
/**/
|
26 |
-
return apply_filters ("ws_plugin__s2member_force_demotion_role", ($demotion_role = "subscriber"), get_defined_vars ());
|
27 |
-
}
|
28 |
-
}
|
29 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/functions/email-configs.inc.php
CHANGED
@@ -12,7 +12,7 @@ If not, see: <http://www.gnu.org/licenses/>.
|
|
12 |
Direct access denial.
|
13 |
*/
|
14 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
15 |
-
exit("Do not access this file directly.");
|
16 |
/*
|
17 |
Functions that modify the email From: name/address.
|
18 |
*/
|
@@ -50,4 +50,22 @@ if (!function_exists ("_ws_plugin__s2member_email_config_name"))
|
|
50 |
return apply_filters ("_ws_plugin__s2member_email_config_name", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"], get_defined_vars ());
|
51 |
}
|
52 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
?>
|
12 |
Direct access denial.
|
13 |
*/
|
14 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"]))
|
15 |
+
exit ("Do not access this file directly.");
|
16 |
/*
|
17 |
Functions that modify the email From: name/address.
|
18 |
*/
|
50 |
return apply_filters ("_ws_plugin__s2member_email_config_name", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["reg_email_from_name"], get_defined_vars ());
|
51 |
}
|
52 |
}
|
53 |
+
/*
|
54 |
+
Convert primitive Role names in emails sent by WordPress®.
|
55 |
+
Attach to: add_filter("wpmu_signup_user_notification_email");
|
56 |
+
~ Only necessary with this particular email.
|
57 |
+
*/
|
58 |
+
if (!function_exists ("ws_plugin__s2member_ms_nice_email_roles"))
|
59 |
+
{
|
60 |
+
function ws_plugin__s2member_ms_nice_email_roles ($message = FALSE)
|
61 |
+
{
|
62 |
+
eval ('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;');
|
63 |
+
do_action ("ws_plugin__s2member_before_ms_nice_email_roles", get_defined_vars ());
|
64 |
+
unset ($__refs, $__v); /* Unset defined __refs, __v. */
|
65 |
+
/**/
|
66 |
+
$message = preg_replace ("/ as a (subscriber|s2member_level[1-4])/i", " as a Member", $message);
|
67 |
+
/**/
|
68 |
+
return apply_filters ("ws_plugin__s2member_ms_nice_email_roles", $message, get_defined_vars ());
|
69 |
+
}
|
70 |
+
}
|
71 |
?>
|
includes/functions/force-options.inc.php
ADDED
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|