| 1 |
<?php |
| 2 |
/** |
| 3 |
* Custom Registration Fields for s2Member. |
| 4 |
* |
| 5 |
* Copyright: © 2009-2011 |
| 6 |
* {@link http://www.websharks-inc.com/ WebSharks, Inc.} |
| 7 |
* ( coded in the USA ) |
| 8 |
* |
| 9 |
* Released under the terms of the GNU General Public License. |
| 10 |
* You should have received a copy of the GNU General Public License, |
| 11 |
* along with this software. In the main directory, see: /licensing/ |
| 12 |
* If not, see: {@link http://www.gnu.org/licenses/}. |
| 13 |
* |
| 14 |
* @package s2Member\Custom_Reg_Fields |
| 15 |
* @since 3.5 |
| 16 |
*/ |
| 17 |
if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"])) |
| 18 |
exit("Do not access this file directly."); |
| 19 |
/**/ |
| 20 |
if (!class_exists ("c_ws_plugin__s2member_custom_reg_fields")) |
| 21 |
{ |
| 22 |
/** |
| 23 |
* Custom Registration Fields for s2Member. |
| 24 |
* |
| 25 |
* @package s2Member\Custom_Reg_Fields |
| 26 |
* @since 3.5 |
| 27 |
*/ |
| 28 |
class c_ws_plugin__s2member_custom_reg_fields |
| 29 |
{ |
| 30 |
/** |
| 31 |
* Generates all Custom Fields. |
| 32 |
* |
| 33 |
* @package s2Member\Custom_Reg_Fields |
| 34 |
* @since 3.5 |
| 35 |
* |
| 36 |
* @param str $_function Function calling upon this routine. |
| 37 |
* @param array $_field The Field array of configuration options. |
| 38 |
* @param str $_name_prefix The `name=""` attribute prefix. |
| 39 |
* @param str $_id_prefix The `id=""` attribute prefix. |
| 40 |
* @param str $_classes Optional. String of space separated classes that will go inside the Field's `class=""` attribute. |
| 41 |
* @param str $_styles Optional. String of CSS styles that will go inside the Field's `style=""` attribute. |
| 42 |
* @param str|int $_tabindex. Optional numeric tabindex for the `tabindex=""` attribute. |
| 43 |
* @param str $_attrs Optional. Some additional Field attributes and values. |
| 44 |
* @param array $_submission Optional. But should be passed in with any submission data related to this Field. For instance, you might pass in ``$_POST``. |
| 45 |
* @param str|array $_value Optional. The value of this Field, either by default, or from the ``$_submission`` array. |
| 46 |
* @param str $_editable_context Optional. One of `profile|profile-view|registration`. |
| 47 |
* @return str The resulting Custom Field, in HTML format. |
| 48 |
*/ |
| 49 |
public static function 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, $_editable_context = FALSE) |
| 50 |
{ |
| 51 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 52 |
do_action ("ws_plugin__s2member_before_custom_field_gen", get_defined_vars ()); |
| 53 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 54 |
/**/ |
| 55 |
if (!($gen = "") && $_function && is_array ($field = $_field) && !empty ($field["type"]) && !empty ($field["id"]) && $_name_prefix && $_id_prefix) |
| 56 |
{ |
| 57 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 58 |
do_action ("ws_plugin__s2member_during_custom_field_gen_before", get_defined_vars ()); |
| 59 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 60 |
/**/ |
| 61 |
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"])); |
| 62 |
$field_id_class = preg_replace ("/_/", "-", $field_var); |
| 63 |
/**/ |
| 64 |
$name_suffix = (preg_match ("/\[$/", $_name_prefix)) ? ']' : ''; |
| 65 |
$field_name = trim ($_name_prefix . $field_var . $name_suffix); |
| 66 |
/**/ |
| 67 |
$common = ''; /* Common attribute configuration. */ |
| 68 |
$common .= ' name="' . esc_attr ($field_name) . '"'; |
| 69 |
$common .= ' id="' . esc_attr ($_id_prefix . $field_id_class) . '"'; |
| 70 |
$common .= ((!empty ($field["required"]) && $field["required"] === "yes") ? ' aria-required="true"' : ''); |
| 71 |
$common .= ((strlen ($_tabindex)) ? ' tabindex="' . esc_attr ($_tabindex) . '"' : ''); /* No tabindex if empty. */ |
| 72 |
$common .= ((!empty ($field["expected"])) ? ' data-expected="' . esc_attr ($field["expected"]) . '"' : ''); /* Certain data expected? */ |
| 73 |
$common .= (($_editable_context === "profile-view" || (!empty ($field["editable"]) && preg_match ("/^no/", $field["editable"]) && $_editable_context === "profile")) ? ' disabled="disabled"' : ''); |
| 74 |
$common .= (($_classes || !empty ($field["classes"])) ? ' class="' . esc_attr (trim ($_classes . ((!empty ($field["classes"])) ? ' ' . $field["classes"] : ''))) . '"' : ''); |
| 75 |
$common .= (($_styles || !empty ($field["styles"])) ? ' style="' . esc_attr (trim ($_styles . ((!empty ($field["styles"])) ? ' ' . $field["styles"] : ''))) . '"' : ''); |
| 76 |
$common .= (($_attrs || !empty ($field["attrs"])) ? ' ' . trim ($_attrs . ((!empty ($field["attrs"])) ? ' ' . $field["attrs"] : '')) : ''); |
| 77 |
/**/ |
| 78 |
if ($field["type"] === "text") |
| 79 |
{ |
| 80 |
if ($_editable_context === "profile-view") |
| 81 |
$gen = esc_html ((string)$_value); |
| 82 |
/**/ |
| 83 |
else /* Else handle this Field normally. */ |
| 84 |
{ |
| 85 |
$gen = '<input type="text" maxlength="100"'; |
| 86 |
$gen .= ' value="' . format_to_edit ((isset ($field["deflt"]) && strlen ($field["deflt"]) && !$_submission) ? (string)$field["deflt"] : (string)$_value) . '"'; |
| 87 |
$gen .= $common . ' />'; |
| 88 |
} |
| 89 |
} |
| 90 |
/**/ |
| 91 |
else if ($field["type"] === "textarea") |
| 92 |
{ |
| 93 |
if ($_editable_context === "profile-view") |
| 94 |
$gen = nl2br (esc_html ((string)$_value)); |
| 95 |
/**/ |
| 96 |
else /* Else handle this Field normally. */ |
| 97 |
{ |
| 98 |
$gen = '<textarea rows="3"' . $common . '>'; |
| 99 |
$gen .= format_to_edit ((isset ($field["deflt"]) && strlen ($field["deflt"]) && !$_submission) ? (string)$field["deflt"] : (string)$_value); |
| 100 |
$gen .= '</textarea>'; |
| 101 |
} |
| 102 |
} |
| 103 |
/**/ |
| 104 |
else if ($field["type"] === "select" && !empty ($field["options"])) |
| 105 |
{ |
| 106 |
if ($_editable_context === "profile-view") |
| 107 |
{ |
| 108 |
foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $option_line) |
| 109 |
{ |
| 110 |
list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line))); |
| 111 |
if ($option_value === (string)$_value) |
| 112 |
{ |
| 113 |
$gen = $option_label; |
| 114 |
break; |
| 115 |
} |
| 116 |
} |
| 117 |
} |
| 118 |
else /* Else handle this Field normally. */ |
| 119 |
{ |
| 120 |
$gen = '<select' . $common . '>'; |
| 121 |
foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $option_line) |
| 122 |
{ |
| 123 |
list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line))); |
| 124 |
$gen .= '<option value="' . esc_attr ($option_value) . '"' . ((($option_default && !$_submission) || $option_value === (string)$_value) ? ' selected="selected"' : '') . '>' . $option_label . '</option>'; |
| 125 |
} |
| 126 |
$gen .= '</select>'; |
| 127 |
} |
| 128 |
} |
| 129 |
/**/ |
| 130 |
else if ($field["type"] === "selects" && !empty ($field["options"])) |
| 131 |
{ |
| 132 |
if ($_editable_context === "profile-view") |
| 133 |
{ |
| 134 |
foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $option_line) |
| 135 |
{ |
| 136 |
list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line))); |
| 137 |
if (in_array ($option_value, (array)$_value)) |
| 138 |
$gen .= $option_label . ", "; |
| 139 |
} |
| 140 |
$gen = trim ($gen, ", \r\n\t\0\x0B"); |
| 141 |
} |
| 142 |
else /* Else handle this Field normally. */ |
| 143 |
{ |
| 144 |
$common = preg_replace ('/ name\="(.+?)"/', ' name="$1[]"', $common); |
| 145 |
$common = preg_replace ('/ style\="(.+?)"/', ' style="height:auto; $1"', $common); |
| 146 |
/**/ |
| 147 |
$gen = '<select multiple="multiple" size="3"' . $common . '>'; |
| 148 |
foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $option_line) |
| 149 |
{ |
| 150 |
list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line))); |
| 151 |
$gen .= '<option value="' . esc_attr ($option_value) . '"' . ((($option_default && !$_submission) || in_array ($option_value, (array)$_value)) ? ' selected="selected"' : '') . '>' . $option_label . '</option>'; |
| 152 |
} |
| 153 |
$gen .= '</select>'; |
| 154 |
} |
| 155 |
} |
| 156 |
/**/ |
| 157 |
else if ($field["type"] === "checkbox" && !empty ($field["label"])) |
| 158 |
{ |
| 159 |
if ($_editable_context === "profile-view") |
| 160 |
$gen = ((string)$_value) ? "yes" : "no"; |
| 161 |
/**/ |
| 162 |
else /* Else handle this Field normally. */ |
| 163 |
{ |
| 164 |
$gen = '<input type="checkbox" value="1"'; |
| 165 |
$gen .= (((string)$_value) ? ' checked="checked"' : ''); |
| 166 |
$gen .= $common . ' /><label for="' . esc_attr ($_id_prefix . $field_id_class) . '" style="display:inline !important; margin:0 !important;">' . $field["label"] . '</label>'; |
| 167 |
} |
| 168 |
} |
| 169 |
/**/ |
| 170 |
else if ($field["type"] === "pre_checkbox" && !empty ($field["label"])) |
| 171 |
{ |
| 172 |
if ($_editable_context === "profile-view") |
| 173 |
$gen = ((string)$_value) ? "yes" : "no"; |
| 174 |
/**/ |
| 175 |
else /* Else handle this Field normally. */ |
| 176 |
{ |
| 177 |
$gen = '<input type="checkbox" value="1"'; |
| 178 |
$gen .= ((!$_submission || (string)$_value) ? ' checked="checked"' : ''); |
| 179 |
$gen .= $common . ' /><label for="' . esc_attr ($_id_prefix . $field_id_class) . '" style="display:inline !important; margin:0 !important;">' . $field["label"] . '</label>'; |
| 180 |
} |
| 181 |
} |
| 182 |
/**/ |
| 183 |
else if ($field["type"] === "checkboxes" && !empty ($field["options"])) |
| 184 |
{ |
| 185 |
if ($_editable_context === "profile-view") |
| 186 |
{ |
| 187 |
foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $i => $option_line) |
| 188 |
{ |
| 189 |
list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line))); |
| 190 |
if (in_array ($option_value, (array)$_value)) |
| 191 |
$gen .= $option_label . ", "; |
| 192 |
} |
| 193 |
$gen = trim ($gen, ", \r\n\t\0\x0B"); |
| 194 |
} |
| 195 |
else /* Else handle this Field normally. */ |
| 196 |
{ |
| 197 |
$common = preg_replace ('/ name\="(.+?)"/', ' name="$1[]"', $common); |
| 198 |
/**/ |
| 199 |
$sep = apply_filters ("ws_plugin__s2member_custom_field_gen_checkboxes_sep", " ", get_defined_vars ()); |
| 200 |
$opl = apply_filters ("ws_plugin__s2member_custom_field_gen_checkboxes_opl", "ws-plugin--s2member-custom-reg-field-op-l", get_defined_vars ()); |
| 201 |
/**/ |
| 202 |
foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $i => $option_line) |
| 203 |
{ |
| 204 |
$common_i = preg_replace ('/ id\="(.+?)"/', ' id="$1-' . ($i) . '"', $common); |
| 205 |
/**/ |
| 206 |
list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line))); |
| 207 |
/**/ |
| 208 |
$gen .= ($i > 0) ? $sep : ''; /* Separators can be filtered above. */ |
| 209 |
$gen .= '<input type="checkbox" value="' . esc_attr ($option_value) . '"'; |
| 210 |
$gen .= ((($option_default && !$_submission) || in_array ($option_value, (array)$_value)) ? ' checked="checked"' : ''); |
| 211 |
$gen .= $common_i . ' /><label for="' . esc_attr ($_id_prefix . $field_id_class . "-" . $i) . '" class="' . esc_attr ($opl) . '" style="display:inline !important; margin:0 !important;">' . $option_label . '</label>'; |
| 212 |
} |
| 213 |
} |
| 214 |
} |
| 215 |
/**/ |
| 216 |
else if ($field["type"] === "radios" && !empty ($field["options"])) |
| 217 |
{ |
| 218 |
if ($_editable_context === "profile-view") |
| 219 |
{ |
| 220 |
foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $i => $option_line) |
| 221 |
{ |
| 222 |
list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line))); |
| 223 |
if ($option_value === (string)$_value) |
| 224 |
{ |
| 225 |
$gen = $option_label; |
| 226 |
break; |
| 227 |
} |
| 228 |
} |
| 229 |
} |
| 230 |
else /* Else handle this Field normally. */ |
| 231 |
{ |
| 232 |
$sep = apply_filters ("ws_plugin__s2member_custom_field_gen_radios_sep", " ", get_defined_vars ()); |
| 233 |
$opl = apply_filters ("ws_plugin__s2member_custom_field_gen_radios_opl", "ws-plugin--s2member-custom-reg-field-op-l", get_defined_vars ()); |
| 234 |
/**/ |
| 235 |
foreach (preg_split ("/[\r\n\t]+/", $field["options"]) as $i => $option_line) |
| 236 |
{ |
| 237 |
$common_i = preg_replace ('/ id\="(.+?)"/', ' id="$1-' . ($i) . '"', $common); |
| 238 |
/**/ |
| 239 |
list ($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep (preg_split ("/\|/", trim ($option_line))); |
| 240 |
/**/ |
| 241 |
$gen .= ($i > 0) ? $sep : ''; /* Separators can be filtered above. */ |
| 242 |
$gen .= '<input type="radio" value="' . esc_attr ($option_value) . '"'; |
| 243 |
$gen .= ((($option_default && !$_submission) || $option_value === (string)$_value) ? ' checked="checked"' : ''); |
| 244 |
$gen .= $common_i . ' /><label for="' . esc_attr ($_id_prefix . $field_id_class . "-" . $i) . '" class="' . esc_attr ($opl) . '" style="display:inline !important; margin:0 !important;">' . $option_label . '</label>'; |
| 245 |
} |
| 246 |
} |
| 247 |
} |
| 248 |
else /* Default to using a text field. */ |
| 249 |
{ |
| 250 |
if ($_editable_context === "profile-view") |
| 251 |
$gen = esc_html ((string)$_value); |
| 252 |
/**/ |
| 253 |
else /* Else handle this Field normally. */ |
| 254 |
{ |
| 255 |
$gen = '<input type="text" maxlength="100"'; |
| 256 |
$gen .= ' value="' . format_to_edit ((isset ($field["deflt"]) && strlen ($field["deflt"]) && !$_submission) ? (string)$field["deflt"] : (string)$_value) . '"'; |
| 257 |
$gen .= $common . ' />'; |
| 258 |
} |
| 259 |
} |
| 260 |
/**/ |
| 261 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 262 |
do_action ("ws_plugin__s2member_during_custom_field_gen_after", get_defined_vars ()); |
| 263 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 264 |
} |
| 265 |
/**/ |
| 266 |
return apply_filters ("ws_plugin__s2member_custom_field_gen", $gen, get_defined_vars ()); |
| 267 |
} |
| 268 |
/** |
| 269 |
* Determines which Custom Fields apply to a specific Level. |
| 270 |
* |
| 271 |
* @package s2Member\Custom_Reg_Fields |
| 272 |
* @since 3.5 |
| 273 |
* |
| 274 |
* @param str|int $_level Optional. Defaults to the current User's Access Level number. |
| 275 |
* You can either pass in a numeric Level number, or the string `auto-detection`. |
| 276 |
* @param str $_editable_context Optional. One of `profile|profile-view|registration`. |
| 277 |
* @return array Array of Custom Field IDs applicable. |
| 278 |
*/ |
| 279 |
public static function custom_fields_configured_at_level ($_level = "auto-detection", $_editable_context = FALSE) |
| 280 |
{ |
| 281 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 282 |
do_action ("ws_plugin__s2member_before_custom_fields_configured_at_level", get_defined_vars ()); |
| 283 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 284 |
/**/ |
| 285 |
$level = ($_level === "auto-detection") ? c_ws_plugin__s2member_user_access::user_access_level () : $_level; |
| 286 |
if ($_level === "auto-detection" && $level < 0 && ($reg_cookies = c_ws_plugin__s2member_register_access::reg_cookies_ok ()) && extract ($reg_cookies) && preg_match ($GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["membership_item_number_w_level_regex"], $item_number, $m) && !empty ($m[1]) && is_numeric ($m[1])) |
| 287 |
$level = $m[1]; /* A numeric Membership Level # . */ |
| 288 |
/**/ |
| 289 |
$level = ($level !== "any" && (!is_numeric ($level) || $level < 0)) ? 0 : $level; /* Default. */ |
| 290 |
/**/ |
| 291 |
if (($level === "any" || (is_numeric ($level) && $level >= 0)) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) |
| 292 |
{ |
| 293 |
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field) |
| 294 |
if ($level === "any" || $field["levels"] === "all" || in_array ($level, preg_split ("/[;,]+/", preg_replace ("/[^0-9;,]/", "", $field["levels"])))) |
| 295 |
if (empty ($_editable_context) || $_editable_context === "administrative" || ($_editable_context === "registration" && $field["editable"] !== "yes-invisible") || (($_editable_context === "profile" || $_editable_context === "profile-view") && $field["editable"] !== "no-invisible")) |
| 296 |
$configured[] = $field["id"]; /* Add this to the array. */ |
| 297 |
} |
| 298 |
/**/ |
| 299 |
return apply_filters ("ws_plugin__s2member_custom_fields_configured_at_level", ((!empty ($configured)) ? $configured : array ()), get_defined_vars ()); |
| 300 |
} |
| 301 |
/** |
| 302 |
* Adds Custom Fields to: `/wp-signup.php`. |
| 303 |
* |
| 304 |
* For Multisite Blog Farms. |
| 305 |
* |
| 306 |
* @package s2Member\Custom_Reg_Fields |
| 307 |
* @since 3.5 |
| 308 |
* |
| 309 |
* @attaches-to: ``add_action("signup_extra_fields");`` |
| 310 |
* |
| 311 |
* @return null |
| 312 |
* |
| 313 |
* @todo Optimize with ``empty()``. |
| 314 |
*/ |
| 315 |
public static function ms_custom_registration_fields () |
| 316 |
{ |
| 317 |
do_action ("ws_plugin__s2member_before_ms_custom_registration_fields", get_defined_vars ()); |
| 318 |
/**/ |
| 319 |
if (is_multisite () && is_main_site ()) /* Must be Multisite / Main Site. */ |
| 320 |
{ |
| 321 |
$_p = (!empty ($_POST)) ? c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST)) : array (); |
| 322 |
/**/ |
| 323 |
echo '<input type="hidden" name="ws_plugin__s2member_registration" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-registration")) . '" />' . "\n"; |
| 324 |
/**/ |
| 325 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 326 |
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before", get_defined_vars ()); |
| 327 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 328 |
/**/ |
| 329 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"]) |
| 330 |
{ |
| 331 |
echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section"></div>' . "\n"; |
| 332 |
/**/ |
| 333 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 334 |
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_first_name", get_defined_vars ()); |
| 335 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 336 |
/**/ |
| 337 |
echo '<label for="ws-plugin--s2member-custom-reg-field-first-name">First Name *</label>' . "\n"; |
| 338 |
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="' . esc_attr ($_p["ws_plugin__s2member_custom_reg_field_first_name"]) . '" />' . "\n"; |
| 339 |
echo '<br />' . "\n"; |
| 340 |
/**/ |
| 341 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 342 |
do_action ("ws_plugin__s2member_during_ms_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_ms_custom_registration_fields_before_last_name", get_defined_vars ()); |
| 347 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 348 |
/**/ |
| 349 |
echo '<label for="ws-plugin--s2member-custom-reg-field-last-name">Last Name *</label>' . "\n"; |
| 350 |
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="' . esc_attr ($_p["ws_plugin__s2member_custom_reg_field_last_name"]) . '" />' . "\n"; |
| 351 |
echo '<br />' . "\n"; |
| 352 |
/**/ |
| 353 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 354 |
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_last_name", get_defined_vars ()); |
| 355 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 356 |
} |
| 357 |
/**/ |
| 358 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) |
| 359 |
if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection", "registration")) |
| 360 |
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field) |
| 361 |
{ |
| 362 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 363 |
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_custom_fields", get_defined_vars ()); |
| 364 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 365 |
/**/ |
| 366 |
if (in_array ($field["id"], $fields_applicable)) /* Field applicable? */ |
| 367 |
{ |
| 368 |
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"])); |
| 369 |
$field_id_class = preg_replace ("/_/", "-", $field_var); |
| 370 |
/**/ |
| 371 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 372 |
if (apply_filters ("ws_plugin__s2member_during_ms_custom_registration_fields_during_custom_fields_display", true, get_defined_vars ())) |
| 373 |
{ |
| 374 |
if (!empty ($field["section"]) && $field["section"] === "yes") /* Starts a new section? */ |
| 375 |
echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section' . ((!empty ($field["sectitle"])) ? '-title' : '') . '">' . ((!empty ($field["sectitle"])) ? $field["sectitle"] : '') . '</div>'; |
| 376 |
/**/ |
| 377 |
echo '<label for="ws-plugin--s2member-custom-reg-field-' . esc_attr ($field_id_class) . '"' . ((preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '') . '>' . $field["label"] . (($field["required"] === "yes") ? ' *' : '') . '</label>' . ((preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? '<br />' : '') . "\n"; |
| 378 |
echo c_ws_plugin__s2member_custom_reg_fields::custom_field_gen (__FUNCTION__, $field, "ws_plugin__s2member_custom_reg_field_", "ws-plugin--s2member-custom-reg-field-", "ws-plugin--s2member-custom-reg-field", "", "", "", $_p, $_p["ws_plugin__s2member_custom_reg_field_" . $field_var], "registration"); |
| 379 |
echo '<br />' . "\n"; |
| 380 |
} |
| 381 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 382 |
} |
| 383 |
/**/ |
| 384 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 385 |
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_custom_fields", get_defined_vars ()); |
| 386 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 387 |
} |
| 388 |
/**/ |
| 389 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated ()) |
| 390 |
{ |
| 391 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 392 |
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_before_opt_in", get_defined_vars ()); |
| 393 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 394 |
/**/ |
| 395 |
echo '<label for="ws-plugin--s2member-custom-reg-field-opt-in">' . "\n"; |
| 396 |
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 ($_p) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_p["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '') . ' />' . "\n"; |
| 397 |
echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"] . "\n"; |
| 398 |
echo '</label>' . "\n"; |
| 399 |
echo '<br />' . "\n"; |
| 400 |
/**/ |
| 401 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 402 |
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after_opt_in", get_defined_vars ()); |
| 403 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 404 |
} |
| 405 |
/**/ |
| 406 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 407 |
do_action ("ws_plugin__s2member_during_ms_custom_registration_fields_after", get_defined_vars ()); |
| 408 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 409 |
} |
| 410 |
/**/ |
| 411 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 412 |
do_action ("ws_plugin__s2member_after_ms_custom_registration_fields", get_defined_vars ()); |
| 413 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 414 |
/**/ |
| 415 |
return; /* Return for uniformity. */ |
| 416 |
} |
| 417 |
/** |
| 418 |
* Adds Custom Fields to: `/wp-login.php?action=register`. |
| 419 |
* |
| 420 |
* @package s2Member\Custom_Reg_Fields |
| 421 |
* @since 3.5 |
| 422 |
* |
| 423 |
* @attaches-to: ``add_action("register_form");`` |
| 424 |
* |
| 425 |
* @return null |
| 426 |
* |
| 427 |
* @todo Optimize with ``empty()``. |
| 428 |
*/ |
| 429 |
public static function custom_registration_fields () |
| 430 |
{ |
| 431 |
do_action ("ws_plugin__s2member_before_custom_registration_fields", get_defined_vars ()); |
| 432 |
/**/ |
| 433 |
$_p = (!empty ($_POST)) ? c_ws_plugin__s2member_utils_strings::trim_deep (stripslashes_deep ($_POST)) : array (); |
| 434 |
/**/ |
| 435 |
echo '<input type="hidden" name="ws_plugin__s2member_registration" value="' . esc_attr (wp_create_nonce ("ws-plugin--s2member-registration")) . '" />' . "\n"; |
| 436 |
/**/ |
| 437 |
$tabindex = 20; /* Incremented tabindex starting with 20. */ |
| 438 |
/**/ |
| 439 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 440 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_before", get_defined_vars ()); |
| 441 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 442 |
/**/ |
| 443 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"]) |
| 444 |
{ |
| 445 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 446 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_before_user_pass", get_defined_vars ()); |
| 447 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 448 |
/**/ |
| 449 |
echo '<p>' . "\n"; |
| 450 |
/**/ |
| 451 |
echo '<label for="ws-plugin--s2member-custom-reg-field-user-pass1" title="Please type your Password twice to confirm.">' . "\n"; |
| 452 |
echo '<span>Password ( please type it twice ) *</span><br />' . "\n"; |
| 453 |
echo '<input aria-required="true" type="password" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_user_pass1" id="ws-plugin--s2member-custom-reg-field-user-pass1" class="ws-plugin--s2member-custom-reg-field" value="' . format_to_edit ($_p["ws_plugin__s2member_custom_reg_field_user_pass1"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n"; |
| 454 |
echo '</label>' . "\n"; |
| 455 |
/**/ |
| 456 |
echo '<label for="ws-plugin--s2member-custom-reg-field-user-pass2" title="Please type your Password twice to confirm.">' . "\n"; |
| 457 |
echo '<input type="password" maxlength="100" autocomplete="off" name="ws_plugin__s2member_custom_reg_field_user_pass2" id="ws-plugin--s2member-custom-reg-field-user-pass2" class="ws-plugin--s2member-custom-reg-field" value="' . format_to_edit ($_p["ws_plugin__s2member_custom_reg_field_user_pass2"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n"; |
| 458 |
echo '</label>' . "\n"; |
| 459 |
/**/ |
| 460 |
echo '<div id="ws-plugin--s2member-custom-reg-field-user-pass-strength" class="ws-plugin--s2member-password-strength"><em>password strength indicator</em></div>' . "\n"; |
| 461 |
/**/ |
| 462 |
echo '</p>' . "\n"; |
| 463 |
/**/ |
| 464 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 465 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_after_user_pass", get_defined_vars ()); |
| 466 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 467 |
} |
| 468 |
/**/ |
| 469 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"]) |
| 470 |
{ |
| 471 |
echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section"></div>' . "\n"; |
| 472 |
/**/ |
| 473 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 474 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_before_first_name", get_defined_vars ()); |
| 475 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 476 |
/**/ |
| 477 |
echo '<p>' . "\n"; |
| 478 |
echo '<label for="ws-plugin--s2member-custom-reg-field-first-name">' . "\n"; |
| 479 |
echo '<span>First Name *</span><br />' . "\n"; |
| 480 |
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="' . esc_attr ($_p["ws_plugin__s2member_custom_reg_field_first_name"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n"; |
| 481 |
echo '</label>' . "\n"; |
| 482 |
echo '</p>' . "\n"; |
| 483 |
/**/ |
| 484 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 485 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_after_first_name", get_defined_vars ()); |
| 486 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 487 |
/**/ |
| 488 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 489 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_before_last_name", get_defined_vars ()); |
| 490 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 491 |
/**/ |
| 492 |
echo '<p>' . "\n"; |
| 493 |
echo '<label for="ws-plugin--s2member-custom-reg-field-last-name">' . "\n"; |
| 494 |
echo '<span>Last Name *</span><br />' . "\n"; |
| 495 |
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="' . esc_attr ($_p["ws_plugin__s2member_custom_reg_field_last_name"]) . '" tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n"; |
| 496 |
echo '</label>' . "\n"; |
| 497 |
echo '</p>' . "\n"; |
| 498 |
/**/ |
| 499 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 500 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_after_last_name", get_defined_vars ()); |
| 501 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 502 |
} |
| 503 |
/**/ |
| 504 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) |
| 505 |
if ($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level ("auto-detection", "registration")) |
| 506 |
foreach (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field) |
| 507 |
{ |
| 508 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 509 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_before_custom_fields", get_defined_vars ()); |
| 510 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 511 |
/**/ |
| 512 |
if (in_array ($field["id"], $fields_applicable)) /* Field applicable? */ |
| 513 |
{ |
| 514 |
$field_var = preg_replace ("/[^a-z0-9]/i", "_", strtolower ($field["id"])); |
| 515 |
$field_id_class = preg_replace ("/_/", "-", $field_var); |
| 516 |
/**/ |
| 517 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 518 |
if (apply_filters ("ws_plugin__s2member_during_custom_registration_fields_during_custom_fields_display", true, get_defined_vars ())) |
| 519 |
{ |
| 520 |
if (!empty ($field["section"]) && $field["section"] === "yes") /* Starts a new section? */ |
| 521 |
echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section' . ((!empty ($field["sectitle"])) ? '-title' : '') . '">' . ((!empty ($field["sectitle"])) ? $field["sectitle"] : '') . '</div>'; |
| 522 |
/**/ |
| 523 |
echo '<p>' . "\n"; |
| 524 |
echo '<label for="ws-plugin--s2member-custom-reg-field-' . esc_attr ($field_id_class) . '">' . "\n"; |
| 525 |
echo '<span' . ((preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? ' style="display:none;"' : '') . '>' . $field["label"] . (($field["required"] === "yes") ? ' *' : '') . '</span></label>' . ((preg_match ("/^(checkbox|pre_checkbox)$/", $field["type"])) ? '' : '<br />') . "\n"; |
| 526 |
echo c_ws_plugin__s2member_custom_reg_fields::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), "", $_p, $_p["ws_plugin__s2member_custom_reg_field_" . $field_var], "registration"); |
| 527 |
echo '</p>' . "\n"; |
| 528 |
} |
| 529 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 530 |
} |
| 531 |
/**/ |
| 532 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 533 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_after_custom_fields", get_defined_vars ()); |
| 534 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 535 |
} |
| 536 |
/**/ |
| 537 |
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated ()) |
| 538 |
{ |
| 539 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 540 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_before_opt_in", get_defined_vars ()); |
| 541 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 542 |
/**/ |
| 543 |
echo '<p>' . "\n"; |
| 544 |
echo '<label for="ws-plugin--s2member-custom-reg-field-opt-in">' . "\n"; |
| 545 |
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 ($_p) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] == 1) || $_p["ws_plugin__s2member_custom_reg_field_opt_in"]) ? ' checked="checked"' : '') . ' tabindex="' . esc_attr (($tabindex = $tabindex + 10)) . '" />' . "\n"; |
| 546 |
echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"] . "\n"; |
| 547 |
echo '</label>' . "\n"; |
| 548 |
echo '</p>' . "\n"; |
| 549 |
/**/ |
| 550 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 551 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_after_opt_in", get_defined_vars ()); |
| 552 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 553 |
} |
| 554 |
/**/ |
| 555 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 556 |
do_action ("ws_plugin__s2member_during_custom_registration_fields_after", get_defined_vars ()); |
| 557 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 558 |
/**/ |
| 559 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 560 |
do_action ("ws_plugin__s2member_after_custom_registration_fields", get_defined_vars ()); |
| 561 |
unset ($__refs, $__v); /* Unset defined __refs, __v. */ |
| 562 |
/**/ |
| 563 |
return; /* Return for uniformity. */ |
| 564 |
} |
| 565 |
} |
| 566 |
} |
| 567 |
?> |