| 1 |
<?php |
| 2 |
/** |
| 3 |
* Custom Registration/Profile 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/Profile 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 attributes. */ |
| 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 .= (( /* Certain data expected? */!empty($field["expected"])) ? ' data-expected="'.esc_attr($field["expected"]).'"' : ''); |
| 73 |
$common .= (($_editable_context === "profile-view" || (!empty($field["editable"]) && strpos($field["editable"], "no") === 0 && $_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 normally. */ |
| 84 |
{ |
| 85 |
$gen = '<input type="text" maxlength="100" autocomplete="off"'; |
| 86 |
$gen .= ' value="'.format_to_edit((!$_submission && isset($field["deflt"]) && strlen((string)$field["deflt"])) ? (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 normally. */ |
| 97 |
{ |
| 98 |
$gen = '<textarea rows="3"'.$common.'>'; |
| 99 |
$gen .= format_to_edit((!$_submission && isset($field["deflt"]) && strlen((string)$field["deflt"])) ? (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 normally. */ |
| 119 |
{ |
| 120 |
$gen = '<select'.$common.'>'; |
| 121 |
$selected_default_option = false; |
| 122 |
foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $option_line) |
| 123 |
{ |
| 124 |
list($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep(preg_split("/\|/", trim($option_line))); |
| 125 |
$gen .= '<option value="'.esc_attr($option_value).'"'.(((($option_default && !$_submission) || ($option_value === (string)$_value && !$selected_default_option)) && ($selected_default_option = true)) ? ' selected="selected"' : '').'>'.$option_label.'</option>'; |
| 126 |
} |
| 127 |
$gen .= '</select>'; |
| 128 |
} |
| 129 |
} |
| 130 |
/**/ |
| 131 |
else if($field["type"] === "selects" && !empty($field["options"])) |
| 132 |
{ |
| 133 |
if($_editable_context === "profile-view") |
| 134 |
{ |
| 135 |
foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $option_line) |
| 136 |
{ |
| 137 |
list($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep(preg_split("/\|/", trim($option_line))); |
| 138 |
if(in_array($option_value, (array)$_value)) |
| 139 |
$gen .= $option_label.", "; |
| 140 |
} |
| 141 |
$gen = c_ws_plugin__s2member_utils_strings::trim($gen, 0, ","); |
| 142 |
} |
| 143 |
else /* Else handle normally. */ |
| 144 |
{ |
| 145 |
$common = preg_replace('/ name\="(.+?)"/', ' name="$1[]"', $common); |
| 146 |
$common = preg_replace('/ style\="(.+?)"/', ' style="height:auto; $1"', $common); |
| 147 |
/**/ |
| 148 |
$gen = '<select multiple="multiple" size="3"'.$common.'>'; |
| 149 |
foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $option_line) |
| 150 |
{ |
| 151 |
list($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep(preg_split("/\|/", trim($option_line))); |
| 152 |
$gen .= '<option value="'.esc_attr($option_value).'"'.((($option_default && !$_submission) || in_array($option_value, (array)$_value)) ? ' selected="selected"' : '').'>'.$option_label.'</option>'; |
| 153 |
} |
| 154 |
$gen .= '</select>'; |
| 155 |
} |
| 156 |
} |
| 157 |
/**/ |
| 158 |
else if($field["type"] === "checkbox" && !empty($field["label"])) |
| 159 |
{ |
| 160 |
if($_editable_context === "profile-view") |
| 161 |
$gen = ((string)$_value) ? "yes" : "no"; |
| 162 |
/**/ |
| 163 |
else /* Else handle normally. */ |
| 164 |
{ |
| 165 |
$gen = '<input type="checkbox" value="1"'; |
| 166 |
$gen .= (((string)$_value) ? ' checked="checked"' : ''); |
| 167 |
$gen .= $common.' /><label for="'.esc_attr($_id_prefix.$field_id_class).'" style="display:inline !important; margin:0 !important;">'.$field["label"].'</label>'; |
| 168 |
} |
| 169 |
} |
| 170 |
/**/ |
| 171 |
else if($field["type"] === "pre_checkbox" && !empty($field["label"])) |
| 172 |
{ |
| 173 |
if($_editable_context === "profile-view") |
| 174 |
$gen = ((string)$_value) ? "yes" : "no"; |
| 175 |
/**/ |
| 176 |
else /* Else handle normally. */ |
| 177 |
{ |
| 178 |
$gen = '<input type="checkbox" value="1"'; |
| 179 |
$gen .= ((!$_submission || (string)$_value) ? ' checked="checked"' : ''); |
| 180 |
$gen .= $common.' /><label for="'.esc_attr($_id_prefix.$field_id_class).'" style="display:inline !important; margin:0 !important;">'.$field["label"].'</label>'; |
| 181 |
} |
| 182 |
} |
| 183 |
/**/ |
| 184 |
else if($field["type"] === "checkboxes" && !empty($field["options"])) |
| 185 |
{ |
| 186 |
if($_editable_context === "profile-view") |
| 187 |
{ |
| 188 |
foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $i => $option_line) |
| 189 |
{ |
| 190 |
list($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep(preg_split("/\|/", trim($option_line))); |
| 191 |
if(in_array($option_value, (array)$_value)) |
| 192 |
$gen .= $option_label.", "; |
| 193 |
} |
| 194 |
$gen = c_ws_plugin__s2member_utils_strings::trim($gen, 0, ","); |
| 195 |
} |
| 196 |
else /* Else handle normally. */ |
| 197 |
{ |
| 198 |
$common = preg_replace('/ name\="(.+?)"/', ' name="$1[]"', $common); |
| 199 |
/**/ |
| 200 |
$sep = apply_filters("ws_plugin__s2member_custom_field_gen_checkboxes_sep", " ", get_defined_vars()); |
| 201 |
$opl = apply_filters("ws_plugin__s2member_custom_field_gen_checkboxes_opl", "ws-plugin--s2member-custom-reg-field-op-l", get_defined_vars()); |
| 202 |
/**/ |
| 203 |
foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $i => $option_line) |
| 204 |
{ |
| 205 |
$common_i = preg_replace('/ id\="(.+?)"/', ' id="$1-'.($i).'"', $common); |
| 206 |
/**/ |
| 207 |
list($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep(preg_split("/\|/", trim($option_line))); |
| 208 |
/**/ |
| 209 |
$gen .= ($i > 0) ? $sep : ''; /* Separators can be filtered above. */ |
| 210 |
$gen .= '<input type="checkbox" value="'.esc_attr($option_value).'"'; |
| 211 |
$gen .= ((($option_default && !$_submission) || in_array($option_value, (array)$_value)) ? ' checked="checked"' : ''); |
| 212 |
$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>'; |
| 213 |
} |
| 214 |
} |
| 215 |
} |
| 216 |
/**/ |
| 217 |
else if($field["type"] === "radios" && !empty($field["options"])) |
| 218 |
{ |
| 219 |
if($_editable_context === "profile-view") |
| 220 |
{ |
| 221 |
foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $i => $option_line) |
| 222 |
{ |
| 223 |
list($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep(preg_split("/\|/", trim($option_line))); |
| 224 |
if($option_value === (string)$_value) |
| 225 |
{ |
| 226 |
$gen = $option_label; |
| 227 |
break; |
| 228 |
} |
| 229 |
} |
| 230 |
} |
| 231 |
else /* Else handle normally. */ |
| 232 |
{ |
| 233 |
$sep = apply_filters("ws_plugin__s2member_custom_field_gen_radios_sep", " ", get_defined_vars()); |
| 234 |
$opl = apply_filters("ws_plugin__s2member_custom_field_gen_radios_opl", "ws-plugin--s2member-custom-reg-field-op-l", get_defined_vars()); |
| 235 |
/**/ |
| 236 |
foreach(preg_split("/[\r\n\t]+/", $field["options"]) as $i => $option_line) |
| 237 |
{ |
| 238 |
$common_i = preg_replace('/ id\="(.+?)"/', ' id="$1-'.($i).'"', $common); |
| 239 |
/**/ |
| 240 |
list($option_value, $option_label, $option_default) = c_ws_plugin__s2member_utils_strings::trim_deep(preg_split("/\|/", trim($option_line))); |
| 241 |
/**/ |
| 242 |
$gen .= ($i > 0) ? $sep : ''; /* Separators can be filtered above. */ |
| 243 |
$gen .= '<input type="radio" value="'.esc_attr($option_value).'"'; |
| 244 |
$gen .= ((($option_default && !$_submission) || $option_value === (string)$_value) ? ' checked="checked"' : ''); |
| 245 |
$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>'; |
| 246 |
} |
| 247 |
} |
| 248 |
} |
| 249 |
else /* Default to a text field input type when nothing matches. */ |
| 250 |
{ |
| 251 |
if($_editable_context === "profile-view") |
| 252 |
$gen = esc_html((string)$_value); |
| 253 |
/**/ |
| 254 |
else /* Else handle normally. */ |
| 255 |
{ |
| 256 |
$gen = '<input type="text" maxlength="100" autocomplete="off"'; |
| 257 |
$gen .= ' value="'.format_to_edit((!$_submission && isset($field["deflt"]) && strlen((string)$field["deflt"])) ? (string)$field["deflt"] : (string)$_value).'"'; |
| 258 |
$gen .= $common.' />'; |
| 259 |
} |
| 260 |
} |
| 261 |
/**/ |
| 262 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 263 |
do_action("ws_plugin__s2member_during_custom_field_gen_after", get_defined_vars()); |
| 264 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 265 |
} |
| 266 |
/**/ |
| 267 |
return apply_filters("ws_plugin__s2member_custom_field_gen", $gen, get_defined_vars()); |
| 268 |
} |
| 269 |
/** |
| 270 |
* Determines which Custom Fields apply to a specific Level. |
| 271 |
* |
| 272 |
* @package s2Member\Custom_Reg_Fields |
| 273 |
* @since 3.5 |
| 274 |
* |
| 275 |
* @param str|int $_level Optional. Defaults to the current User's Access Level number. |
| 276 |
* You can either pass in a numeric Level number, or the string `auto-detection`. |
| 277 |
* @param str $_editable_context Optional. One of `profile|profile-view|registration`. |
| 278 |
* @return array Array of Custom Field IDs applicable. |
| 279 |
*/ |
| 280 |
public static function custom_fields_configured_at_level($_level = "auto-detection", $_editable_context = FALSE) |
| 281 |
{ |
| 282 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 283 |
do_action("ws_plugin__s2member_before_custom_fields_configured_at_level", get_defined_vars()); |
| 284 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 285 |
/**/ |
| 286 |
$level = ($_level === "auto-detection") ? c_ws_plugin__s2member_user_access::user_access_level() : $_level; |
| 287 |
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])) |
| 288 |
$level = /* A numeric Membership Level # . */ $m[1]; |
| 289 |
/**/ |
| 290 |
$level = ($level !== "any" && (!is_numeric($level) || $level < 0)) ? 0 : /* Default. */ $level; |
| 291 |
/**/ |
| 292 |
if(($level === "any" || (is_numeric($level) && $level >= 0)) && $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) |
| 293 |
{ |
| 294 |
foreach(json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field) |
| 295 |
if($level === "any" || $field["levels"] === "all" || in_array($level, preg_split("/[;,]+/", preg_replace("/[^0-9;,]/", "", $field["levels"])))) |
| 296 |
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")) |
| 297 |
$configured[] = $field["id"]; /* Add this to the array. */ |
| 298 |
} |
| 299 |
/**/ |
| 300 |
return apply_filters("ws_plugin__s2member_custom_fields_configured_at_level", ((!empty($configured)) ? $configured : array()), get_defined_vars()); |
| 301 |
} |
| 302 |
/** |
| 303 |
* Adds Custom Fields to: `/wp-signup.php`. |
| 304 |
* |
| 305 |
* For Multisite Blog Farms. |
| 306 |
* |
| 307 |
* @package s2Member\Custom_Reg_Fields |
| 308 |
* @since 3.5 |
| 309 |
* |
| 310 |
* @attaches-to ``add_action("signup_extra_fields");`` |
| 311 |
* |
| 312 |
* @return null |
| 313 |
* |
| 314 |
* @todo Optimize with ``empty()``. |
| 315 |
*/ |
| 316 |
public static function ms_custom_registration_fields() |
| 317 |
{ |
| 318 |
do_action("ws_plugin__s2member_before_ms_custom_registration_fields", get_defined_vars()); |
| 319 |
/**/ |
| 320 |
if(is_multisite() && is_main_site()) /* Must be Main Site of a Network. */ |
| 321 |
{ |
| 322 |
$_p = (!empty($_POST)) ? c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST)) : array(); |
| 323 |
/**/ |
| 324 |
echo '<input type="hidden" name="ws_plugin__s2member_registration" value="'.esc_attr(wp_create_nonce("ws-plugin--s2member-registration")).'" />'."\n"; |
| 325 |
/**/ |
| 326 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 327 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_before", get_defined_vars()); |
| 328 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 329 |
/**/ |
| 330 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"]) |
| 331 |
{ |
| 332 |
echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section"></div>'."\n"; |
| 333 |
/**/ |
| 334 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 335 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_before_first_name", get_defined_vars()); |
| 336 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 337 |
/**/ |
| 338 |
echo '<label for="ws-plugin--s2member-custom-reg-field-first-name">'._x("First Name", "s2member-front", "s2member").' *</label>'."\n"; |
| 339 |
echo '<input type="text" aria-required="true" maxlength="100" autocomplete="off" 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"; |
| 340 |
echo '<br />'."\n"; |
| 341 |
/**/ |
| 342 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 343 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_after_first_name", get_defined_vars()); |
| 344 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 345 |
/**/ |
| 346 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 347 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_before_last_name", get_defined_vars()); |
| 348 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 349 |
/**/ |
| 350 |
echo '<label for="ws-plugin--s2member-custom-reg-field-last-name">'._x("Last Name", "s2member-front", "s2member").' *</label>'."\n"; |
| 351 |
echo '<input type="text" aria-required="true" maxlength="100" autocomplete="off" 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"; |
| 352 |
echo '<br />'."\n"; |
| 353 |
/**/ |
| 354 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 355 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_after_last_name", get_defined_vars()); |
| 356 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 357 |
} |
| 358 |
/**/ |
| 359 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) |
| 360 |
if($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level("auto-detection", "registration")) |
| 361 |
foreach(json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field) |
| 362 |
{ |
| 363 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 364 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_before_custom_fields", get_defined_vars()); |
| 365 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 366 |
/**/ |
| 367 |
if(in_array($field["id"], $fields_applicable)) /* Field applicable? */ |
| 368 |
{ |
| 369 |
$field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"])); |
| 370 |
$field_id_class = preg_replace("/_/", "-", $field_var); |
| 371 |
/**/ |
| 372 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 373 |
if(apply_filters("ws_plugin__s2member_during_ms_custom_registration_fields_during_custom_fields_display", true, get_defined_vars())) |
| 374 |
{ |
| 375 |
if(!empty($field["section"]) && $field["section"] === "yes") /* Starts a new section? */ |
| 376 |
echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section'.((!empty($field["sectitle"])) ? '-title' : '').'">'.((!empty($field["sectitle"])) ? $field["sectitle"] : '').'</div>'; |
| 377 |
/**/ |
| 378 |
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"; |
| 379 |
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"); |
| 380 |
echo '<br />'."\n"; |
| 381 |
} |
| 382 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 383 |
} |
| 384 |
/**/ |
| 385 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 386 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_after_custom_fields", get_defined_vars()); |
| 387 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 388 |
} |
| 389 |
/**/ |
| 390 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated()) |
| 391 |
{ |
| 392 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 393 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_before_opt_in", get_defined_vars()); |
| 394 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 395 |
/**/ |
| 396 |
echo '<label for="ws-plugin--s2member-custom-reg-field-opt-in">'."\n"; |
| 397 |
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"; |
| 398 |
echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"]."\n"; |
| 399 |
echo '</label>'."\n"; |
| 400 |
echo '<br />'."\n"; |
| 401 |
/**/ |
| 402 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 403 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_after_opt_in", get_defined_vars()); |
| 404 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 405 |
} |
| 406 |
/**/ |
| 407 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 408 |
do_action("ws_plugin__s2member_during_ms_custom_registration_fields_after", get_defined_vars()); |
| 409 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 410 |
} |
| 411 |
/**/ |
| 412 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 413 |
do_action("ws_plugin__s2member_after_ms_custom_registration_fields", get_defined_vars()); |
| 414 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 415 |
/**/ |
| 416 |
return; /* Return for uniformity. */ |
| 417 |
} |
| 418 |
/** |
| 419 |
* Adds Custom Fields to: `/wp-login.php?action=register`. |
| 420 |
* |
| 421 |
* @package s2Member\Custom_Reg_Fields |
| 422 |
* @since 3.5 |
| 423 |
* |
| 424 |
* @attaches-to ``add_action("register_form");`` |
| 425 |
* |
| 426 |
* @return null |
| 427 |
* |
| 428 |
* @todo Optimize with ``empty()``. |
| 429 |
*/ |
| 430 |
public static function custom_registration_fields() |
| 431 |
{ |
| 432 |
do_action("ws_plugin__s2member_before_custom_registration_fields", get_defined_vars()); |
| 433 |
/**/ |
| 434 |
$_p = (!empty($_POST)) ? c_ws_plugin__s2member_utils_strings::trim_deep(stripslashes_deep($_POST)) : array(); |
| 435 |
/**/ |
| 436 |
echo '<input type="hidden" name="ws_plugin__s2member_registration" value="'.esc_attr(wp_create_nonce("ws-plugin--s2member-registration")).'" />'."\n"; |
| 437 |
/**/ |
| 438 |
$tabindex = 20; /* Incremented tabindex starting with 20. */ |
| 439 |
/**/ |
| 440 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 441 |
do_action("ws_plugin__s2member_during_custom_registration_fields_before", get_defined_vars()); |
| 442 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 443 |
/**/ |
| 444 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_password"]) |
| 445 |
{ |
| 446 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 447 |
do_action("ws_plugin__s2member_during_custom_registration_fields_before_user_pass", get_defined_vars()); |
| 448 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 449 |
/**/ |
| 450 |
echo '<p>'."\n"; |
| 451 |
/**/ |
| 452 |
echo '<label for="ws-plugin--s2member-custom-reg-field-user-pass1" title="'.esc_attr(_x("Please type your Password twice to confirm.", "s2member-front", "s2member")).'">'."\n"; |
| 453 |
echo '<span>'._x("Password ( please type it twice )", "s2member-front", "s2member").' *</span><br />'."\n"; |
| 454 |
echo '<input type="password" aria-required="true" 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"; |
| 455 |
echo '</label>'."\n"; |
| 456 |
/**/ |
| 457 |
echo '<label for="ws-plugin--s2member-custom-reg-field-user-pass2" title="'.esc_attr(_x("Please type your Password twice to confirm.", "s2member-front", "s2member")).'">'."\n"; |
| 458 |
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"; |
| 459 |
echo '</label>'."\n"; |
| 460 |
/**/ |
| 461 |
echo '<div id="ws-plugin--s2member-custom-reg-field-user-pass-strength" class="ws-plugin--s2member-password-strength"><em>'._x("password strength indicator", "s2member-front", "s2member").'</em></div>'."\n"; |
| 462 |
/**/ |
| 463 |
echo '</p>'."\n"; |
| 464 |
/**/ |
| 465 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 466 |
do_action("ws_plugin__s2member_during_custom_registration_fields_after_user_pass", get_defined_vars()); |
| 467 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 468 |
} |
| 469 |
/**/ |
| 470 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_names"]) |
| 471 |
{ |
| 472 |
echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section"></div>'."\n"; |
| 473 |
/**/ |
| 474 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 475 |
do_action("ws_plugin__s2member_during_custom_registration_fields_before_first_name", get_defined_vars()); |
| 476 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 477 |
/**/ |
| 478 |
echo '<p>'."\n"; |
| 479 |
echo '<label for="ws-plugin--s2member-custom-reg-field-first-name">'."\n"; |
| 480 |
echo '<span>'._x("First Name", "s2member-front", "s2member").' *</span><br />'."\n"; |
| 481 |
echo '<input type="text" aria-required="true" maxlength="100" autocomplete="off" 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"; |
| 482 |
echo '</label>'."\n"; |
| 483 |
echo '</p>'."\n"; |
| 484 |
/**/ |
| 485 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 486 |
do_action("ws_plugin__s2member_during_custom_registration_fields_after_first_name", get_defined_vars()); |
| 487 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 488 |
/**/ |
| 489 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 490 |
do_action("ws_plugin__s2member_during_custom_registration_fields_before_last_name", get_defined_vars()); |
| 491 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 492 |
/**/ |
| 493 |
echo '<p>'."\n"; |
| 494 |
echo '<label for="ws-plugin--s2member-custom-reg-field-last-name">'."\n"; |
| 495 |
echo '<span>'._x("Last Name", "s2member-front", "s2member").' *</span><br />'."\n"; |
| 496 |
echo '<input type="text" aria-required="true" maxlength="100" autocomplete="off" 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"; |
| 497 |
echo '</label>'."\n"; |
| 498 |
echo '</p>'."\n"; |
| 499 |
/**/ |
| 500 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 501 |
do_action("ws_plugin__s2member_during_custom_registration_fields_after_last_name", get_defined_vars()); |
| 502 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 503 |
} |
| 504 |
/**/ |
| 505 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) |
| 506 |
if($fields_applicable = c_ws_plugin__s2member_custom_reg_fields::custom_fields_configured_at_level("auto-detection", "registration")) |
| 507 |
{ |
| 508 |
$tabindex = $tabindex + 9; /* Start tabindex at +9 ( +1 below ). */ |
| 509 |
/**/ |
| 510 |
foreach(json_decode($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"], true) as $field) |
| 511 |
{ |
| 512 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 513 |
do_action("ws_plugin__s2member_during_custom_registration_fields_before_custom_fields", get_defined_vars()); |
| 514 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 515 |
/**/ |
| 516 |
if(in_array($field["id"], $fields_applicable)) /* Field applicable? */ |
| 517 |
{ |
| 518 |
$field_var = preg_replace("/[^a-z0-9]/i", "_", strtolower($field["id"])); |
| 519 |
$field_id_class = preg_replace("/_/", "-", $field_var); |
| 520 |
/**/ |
| 521 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 522 |
if(apply_filters("ws_plugin__s2member_during_custom_registration_fields_during_custom_fields_display", true, get_defined_vars())) |
| 523 |
{ |
| 524 |
if(!empty($field["section"]) && $field["section"] === "yes") /* Starts a new section? */ |
| 525 |
echo '<div class="ws-plugin--s2member-custom-reg-field-divider-section'.((!empty($field["sectitle"])) ? '-title' : '').'">'.((!empty($field["sectitle"])) ? $field["sectitle"] : '').'</div>'; |
| 526 |
/**/ |
| 527 |
echo '<p>'."\n"; |
| 528 |
echo '<label for="ws-plugin--s2member-custom-reg-field-'.esc_attr($field_id_class).'">'."\n"; |
| 529 |
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"; |
| 530 |
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 + 1), "", $_p, $_p["ws_plugin__s2member_custom_reg_field_".$field_var], "registration"); |
| 531 |
echo '</p>'."\n"; |
| 532 |
} |
| 533 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 534 |
} |
| 535 |
/**/ |
| 536 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 537 |
do_action("ws_plugin__s2member_during_custom_registration_fields_after_custom_fields", get_defined_vars()); |
| 538 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 539 |
} |
| 540 |
} |
| 541 |
/**/ |
| 542 |
if($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in"] && c_ws_plugin__s2member_list_servers::list_servers_integrated()) |
| 543 |
{ |
| 544 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 545 |
do_action("ws_plugin__s2member_during_custom_registration_fields_before_opt_in", get_defined_vars()); |
| 546 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 547 |
/**/ |
| 548 |
echo '<p>'."\n"; |
| 549 |
echo '<label for="ws-plugin--s2member-custom-reg-field-opt-in">'."\n"; |
| 550 |
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"; |
| 551 |
echo $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_opt_in_label"]."\n"; |
| 552 |
echo '</label>'."\n"; |
| 553 |
echo '</p>'."\n"; |
| 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_opt_in", get_defined_vars()); |
| 557 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 558 |
} |
| 559 |
/**/ |
| 560 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 561 |
do_action("ws_plugin__s2member_during_custom_registration_fields_after", get_defined_vars()); |
| 562 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 563 |
/**/ |
| 564 |
eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); |
| 565 |
do_action("ws_plugin__s2member_after_custom_registration_fields", get_defined_vars()); |
| 566 |
unset($__refs, $__v); /* Unset defined __refs, __v. */ |
| 567 |
/**/ |
| 568 |
return; /* Return for uniformity. */ |
| 569 |
} |
| 570 |
} |
| 571 |
} |
| 572 |
?> |