PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 1.1.9
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v1.1.9
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / front-end / wppb.register.php

wppb.register.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 1.1.9, at front-end/wppb.register.php

844 lines 42.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 function wppb_front_end_register($atts){
4 ob_start();
5 $wppb_defaultOptions = get_option('wppb_default_settings');
6 global $current_user;
7 global $wp_roles;
8 global $wpdb;
9 global $error;
10 $agreed = true;
11 $new_user = 'no';
12 $registerFilterArray = array();
13 $extraFieldsErrorHolder = array(); //we will use this array to store the ID's of the extra-fields left uncompleted
14 get_currentuserinfo();
15
16 /* variables used to verify if all required fields were submitted*/
17 $firstnameComplete = 'yes';
18 $lastnameComplete = 'yes';
19 $nicknameComplete = 'yes';
20 $websiteComplete = 'yes';
21 $aimComplete = 'yes';
22 $yahooComplete = 'yes';
23 $jabberComplete = 'yes';
24 $bioComplete = 'yes';
25 /* END variables used to verify if all required fields were submitted*/
26
27
28 /* Load registration file. */
29 require_once( ABSPATH . WPINC . '/registration.php' );
30
31 /* Check if users can register. */
32 $registration = get_option( 'users_can_register' );
33
34
35 //fallback if the file was largen then post_max_size, case in which no errors can be saved in $_FILES[fileName]['error']
36 if (empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
37 $registerFilterArray['noPostError'] = '
38 <p class="error">'.
39 __('The information size you were trying to submit was larger than', 'profilebuilder') .' '. ServerMaxUploadSizeMega .'b!<br/>'.
40 __('This is usually caused by a large file(s) trying to be uploaded.', 'profilebuilder') .'<br/>'.
41 __('Since it was also larger than', 'profilebuilder') .' '. ServerMaxPostSizeMega .'b, '. __('no additional information is available.', 'profilebuilder'). '<br/>'.
42 __('The user was NOT created!', 'profilebuilder') .
43 '</p>';
44 $registerFilterArray['noPostError'] = apply_filters('wppb_register_no_post_error_message', $registerFilterArray['noPostError']);
45 echo $registerFilterArray['noPostError'];
46 }
47
48 /* If user registered, input info. */
49 if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'adduser' && wp_verify_nonce($_POST['register_nonce_field'],'verify_true_registration') ) {
50 //global $wp_roles;
51
52 //get value sent in the shortcode as parameter, default to "subscriber" if not set
53 extract(shortcode_atts(array('role' => 'subscriber'), $atts));
54
55 //check if the specified role exists in the database, else fall back to the "safe-zone"
56 $found = get_role($role);
57
58 if ($found != null)
59 $aprovedRole = $role;
60 else $aprovedRole = get_option( 'default_role' );
61
62 $user_pass = esc_attr( $_POST['passw1'] );
63
64 /* use filters to modify (if needed) the posted data before creating the user-data */
65 $user_pass = apply_filters('wppb_register_posted_password', $user_pass);
66 $_POST['user_name'] = apply_filters('wppb_register_posted_email', $_POST['user_name']);
67 $_POST['first_name'] = apply_filters('wppb_register_posted_first_name', $_POST['first_name']);
68 $_POST['last_name'] = apply_filters('wppb_register_posted_last_name', $_POST['last_name']);
69 $_POST['nickname'] = apply_filters('wppb_register_posted_nickname', $_POST['nickname']);
70 $_POST['email'] = apply_filters('wppb_register_posted_email', $_POST['email']);
71 $_POST['website'] = apply_filters('wppb_register_posted_website', $_POST['website']);
72 $_POST['aim'] = apply_filters('wppb_register_posted_aim', $_POST['aim']);
73 $_POST['yim'] = apply_filters('wppb_register_posted_yahoo', $_POST['yim']);
74 $_POST['jabber'] = apply_filters('wppb_register_posted_jabber', $_POST['jabber']);
75 $_POST['description'] = apply_filters('wppb_register_posted_bio', $_POST['description']);
76 /* END use filters to modify (if needed) the posted data before creating the user-data */
77
78 $userdata = array(
79 'user_pass' => $user_pass,
80 'user_login' => esc_attr( $_POST['user_name'] ),
81 'first_name' => esc_attr( $_POST['first_name'] ),
82 'last_name' => esc_attr( $_POST['last_name'] ),
83 'nickname' => esc_attr( $_POST['nickname'] ),
84 'user_email' => esc_attr( $_POST['email'] ),
85 'user_url' => esc_attr( $_POST['website'] ),
86 'aim' => esc_attr( $_POST['aim'] ),
87 'yim' => esc_attr( $_POST['yim'] ),
88 'jabber' => esc_attr( $_POST['jabber'] ),
89 'description' => esc_attr( $_POST['description'] ),
90 'role' => $aprovedRole);
91
92 //get required and shown fields
93 $wppb_defaultOptions = get_option('wppb_default_settings');
94
95 //check if the user agreed to the terms and conditions (if it was set)
96 $wppb_premium = wppb_plugin_dir . '/premium/functions/';
97 if (file_exists ( $wppb_premium.'extra.fields.php' )){
98 $wppbFetchArray = get_option('wppb_custom_fields');
99 foreach ( $wppbFetchArray as $key => $value){
100 switch ($value['item_type']) {
101 case "agreeToTerms":{
102 $agreed = false;
103 if ( (isset($_POST[$value['item_id'].$value['id']] )) && ($_POST[$value['item_id'].$value['id']] == 'agree'))
104 $agreed = true;
105 break;
106 }
107 }
108 }
109 }
110
111 $registerFilterArray['extraError'] = ''; //this is for creating extra error message and bypassing registration
112 $registerFilterArray['extraError'] = apply_filters('wppb_register_extra_error', $registerFilterArray['extraError']);
113
114 /* check if all the required fields were completed */
115 if($wppb_defaultOptions['firstname'] == 'show'){
116 if (($wppb_defaultOptions['firstnameRequired'] == 'yes') && (trim($_POST['first_name']) == ''))
117 $firstnameComplete = 'no';
118 }elseif($wppb_defaultOptions['lastname'] == 'show'){
119 if (($wppb_defaultOptions['lastnameRequired'] == 'yes') && (trim($_POST['last_name']) == ''))
120 $lastnameComplete = 'no';
121 }elseif($wppb_defaultOptions['nickname'] == 'show'){
122 if (($wppb_defaultOptions['nicknameRequired'] == 'yes') && (trim($_POST['nickname']) == ''))
123 $nicknameComplete = 'no';
124 }elseif($wppb_defaultOptions['website'] == 'show'){
125 if (($wppb_defaultOptions['websiteRequired'] == 'yes') && (trim($_POST['website']) == ''))
126 $websiteComplete = 'no';
127 }elseif($wppb_defaultOptions['aim'] == 'show'){
128 if (($wppb_defaultOptions['aimRequired'] == 'yes') && (trim($_POST['aim']) == ''))
129 $aimComplete = 'no';
130 }elseif($wppb_defaultOptions['yahoo'] == 'show'){
131 if (($wppb_defaultOptions['yahooRequired'] == 'yes') && (trim($_POST['yahoo']) == ''))
132 $yahooComplete = 'no';
133 }elseif($wppb_defaultOptions['jabber'] == 'show'){
134 if (($wppb_defaultOptions['jabberRequired'] == 'yes') && (trim($_POST['jabber']) == ''))
135 $jabberComplete = 'no';
136 }elseif($wppb_defaultOptions['bio'] == 'show'){
137 if (($wppb_defaultOptions['bioRequired'] == 'yes') && (trim($_POST['description']) == ''))
138 $bioComplete = 'no';
139 }
140
141 // check the extra fields also
142 $wppb_premium = wppb_plugin_dir . '/premium/functions/';
143 if (file_exists ( $wppb_premium.'extra.fields.php' )){
144 $wppbFetchArray = get_option('wppb_custom_fields');
145 foreach ( $wppbFetchArray as $key => $value){
146 switch ($value['item_type']) {
147 case "input":{
148 $_POST[$value['item_id'].$value['id']] = apply_filters('wppb_register_input_custom_field_'.$value['id'], $_POST[$value['item_id'].$value['id']]);
149 if ($value['item_required'] != null){
150 if ($value['item_required'] == 'yes'){
151 if (trim($_POST[$value['item_id'].$value['id']]) == '')
152 array_push($extraFieldsErrorHolder, $value['id']);
153 }
154 }
155 break;
156 }
157 case "checkbox":{
158 $checkboxOption = '';
159 $checkboxValue = explode(',', $value['item_options']);
160 foreach($checkboxValue as $thisValue){
161 $thisValue = str_replace(' ', '#@space@#', $thisValue); //we need to escape the space-codification we sent earlier in the post
162 if (isset($_POST[$thisValue.$value['id']])){
163 $localValue = str_replace('#@space@#', ' ', $_POST[$thisValue.$value['id']]);
164 $checkboxOption = $checkboxOption.$localValue.',';
165 }
166 }
167
168 if ($value['item_required'] != null){
169 if ($value['item_required'] == 'yes'){
170 if (trim($checkboxOption) == '')
171 array_push($extraFieldsErrorHolder, $value['id']);
172 }
173 }
174 break;
175 }
176 case "radio":{
177 if ($value['item_required'] != null){
178 if ($value['item_required'] == 'yes'){
179 if (trim($_POST[$value['item_id'].$value['id']]) == '')
180 array_push($extraFieldsErrorHolder, $value['id']);
181 }
182 }
183 break;
184 }
185 case "select":{
186 if ($value['item_required'] != null){
187 if ($value['item_required'] == 'yes'){
188 if (trim($_POST[$value['item_id'].$value['id']]) == '')
189 array_push($extraFieldsErrorHolder, $value['id']);
190 }
191 }
192 break;
193 }
194 case "countrySelect":{
195 if ($value['item_required'] != null){
196 if ($value['item_required'] == 'yes'){
197 if (trim($_POST[$value['item_id'].$value['id']]) == '')
198 array_push($extraFieldsErrorHolder, $value['id']);
199 }
200 }
201 break;
202 }
203 case "timeZone":{
204 if ($value['item_required'] != null){
205 if ($value['item_required'] == 'yes'){
206 if (trim($_POST[$value['item_id'].$value['id']]) == '')
207 array_push($extraFieldsErrorHolder, $value['id']);
208 }
209 }
210 break;
211 }
212 case "datepicker":{
213 if ($value['item_required'] != null){
214 if ($value['item_required'] == 'yes'){
215 if (trim($_POST[$value['item_id'].$value['id']]) == '')
216 array_push($extraFieldsErrorHolder, $value['id']);
217 }
218 }
219 break;
220 }
221 case "textarea":{
222 if ($value['item_required'] != null){
223 if ($value['item_required'] == 'yes'){
224 if (trim($_POST[$value['item_id'].$value['id']]) == '')
225 array_push($extraFieldsErrorHolder, $value['id']);
226 }
227 }
228 break;
229 }
230 case "upload":{
231 $uploadedfile = $value['item_type'].$value['id'];
232 if ( (basename( $_FILES[$uploadedfile]['name']) == '')){
233 if ($value['item_required'] != null){
234 if ($value['item_required'] == 'yes')
235 array_push($extraFieldsErrorHolder, $value['id']);
236 }
237 }
238 break;
239 }
240 case "avatar":{
241
242 $uploadedfile = $value['item_type'].$value['id'];
243
244 if ( (basename( $_FILES[$uploadedfile]['name']) == '')){
245 if (($_FILES[$uploadedfile]['type'] != 'image/jpeg') || ($_FILES[$uploadedfile]['type'] != 'image/jpg') || ($_FILES[$uploadedfile]['type'] != 'image/png') || ($_FILES[$uploadedfile]['type'] != 'image/bmp') || ($_FILES[$uploadedfile]['type'] != 'image/pjpeg') || ($_FILES[$uploadedfile]['type'] != 'image/x-png'))
246 if ($value['item_required'] != null){
247 if ($value['item_required'] == 'yes')
248 array_push($extraFieldsErrorHolder, $value['id']);
249 }
250 }
251 break;
252 }
253 }
254 }
255 }
256
257 /* END check if all the required fields were completed */
258
259 if ($registerFilterArray['extraError'] != '')
260 $error = $registerFilterArray['extraError'];
261 elseif ( !$userdata['user_login'] )
262 $error = __('A username is required for registration.', 'profilebuilder');
263 elseif ( username_exists($userdata['user_login']) )
264 $error = __('Sorry, that username already exists!', 'profilebuilder');
265 elseif ( !is_email($userdata['user_email'], true) )
266 $error = __('You must enter a valid email address.', 'profilebuilder');
267 elseif ( email_exists($userdata['user_email']) )
268 $error = __('Sorry, that email address is already used!', 'profilebuilder');
269 elseif (( empty($_POST['passw1'] ) || empty( $_POST['passw2'] )) || ( $_POST['passw1'] != $_POST['passw2'] )){
270 if ( empty($_POST['passw1'] ) || empty( $_POST['passw2'] )) //verify if the user has completed both password fields
271 $error = __('You didn\'t complete one of the password-fields!', 'profilebuilder');
272 elseif ( $_POST['passw1'] != $_POST['passw2'] ) //verify if the the password and the retyped password are a match
273 $error = __('The entered passwords don\'t match!', 'profilebuilder');
274 }
275 elseif ( $agreed == false )
276 $error = __('You must agree to the terms and conditions before registering!', 'profilebuilder');
277 elseif(($firstnameComplete == 'no' || $lastnameComplete == 'no' || $nicknameComplete == 'no' || $websiteComplete == 'no' || $aimComplete == 'no' || $yahooComplete == 'no' || $jabberComplete == 'no' || $bioComplete == 'no' ) || !empty($extraFieldsErrorHolder))
278 $error = __('The account was NOT created!', 'profilebuilder') .'<br/>'. __('(Several required fields were left uncompleted)', 'profilebuilder');
279 else{
280 $registered_name = $_POST['user_name'];
281 $new_user = wp_insert_user( $userdata );
282
283 /* add the extra profile information */
284 $wppb_premium = wppb_plugin_dir . '/premium/functions/';
285 if (file_exists ( $wppb_premium.'extra.fields.php' )){
286 $wppbFetchArray = get_option('wppb_custom_fields');
287 foreach ( $wppbFetchArray as $key => $value){
288 switch ($value['item_type']) {
289 case "input":{
290 add_user_meta( $new_user, 'custom_field_'.$value['id'], esc_attr($_POST[$value['item_id'].$value['id']]) );
291 break;
292 }
293 case "hiddenInput":{
294 add_user_meta( $new_user, 'custom_field_'.$value['id'], esc_attr($_POST[$value['item_id'].$value['id']]) );
295 break;
296 }
297 case "checkbox":{
298 $checkboxOption = '';
299 $checkboxValue = explode(',', $value['item_options']);
300 foreach($checkboxValue as $thisValue){
301 $thisValue = str_replace(' ', '#@space@#', $thisValue); //we need to escape the space-codification we sent earlier in the post
302 if (isset($_POST[$thisValue.$value['id']])){
303 $localValue = str_replace('#@space@#', ' ', $_POST[$thisValue.$value['id']]);
304 $checkboxOption = $checkboxOption.$localValue.',';
305 }
306 }
307
308 add_user_meta( $new_user, 'custom_field_'.$value['id'], $checkboxOption );
309 break;
310 }
311 case "radio":{
312 add_user_meta( $new_user, 'custom_field_'.$value['id'], $_POST[$value['item_id'].$value['id']] );
313 break;
314 }
315 case "select":{
316 add_user_meta( $new_user, 'custom_field_'.$value['id'], $_POST[$value['item_id'].$value['id']] );
317 break;
318 }
319 case "countrySelect":{
320 update_user_meta( $new_user, 'custom_field_'.$value['id'], $_POST[$value['item_id'].$value['id']] );
321 break;
322 }
323 case "timeZone":{
324 update_user_meta( $new_user, 'custom_field_'.$value['id'], $_POST[$value['item_id'].$value['id']] );
325 break;
326 }
327 case "datepicker":{
328 update_user_meta( $new_user, 'custom_field_'.$value['id'], $_POST[$value['item_id'].$value['id']] );
329 break;
330 }
331 case "textarea":{
332 add_user_meta( $new_user, 'custom_field_'.$value['id'], esc_attr($_POST[$value['item_id'].$value['id']]) );
333 break;
334 }
335 case "upload":{
336
337 $uploadedfile = $value['item_type'].$value['id'];
338
339 //first we need to verify if we don't try to upload a 0b or 0 length file
340 if ( (basename( $_FILES[$uploadedfile]['name']) != '')){
341
342 //second we need to verify if the uploaded file size is less then the set file size in php.ini
343 if (($_FILES[$uploadedfile]['size'] < ServerMaxUploadSizeByte) && ($_FILES[$uploadedfile]['size'] !=0)){
344 //we need to prepare the basename of the file, so that ' becomes ` as ' gives an error
345 $fileName = basename( $_FILES[$uploadedfile]['name']);
346 $finalFileName = '';
347
348 for ($i=0; $i < strlen($fileName); $i++){
349 if ($fileName[$i] == "'")
350 $finalFileName .= '`';
351 else $finalFileName .= $fileName[$i];
352 }
353
354 //create the target path for uploading
355 $target_path = "wp-content/uploads/profile_builder/attachments/";
356 $target_path = $target_path . 'userID_'.$new_user.'_attachment_'. $finalFileName;
357
358 if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)){
359 $upFile = get_bloginfo('home').'/'.$target_path;
360 add_user_meta( $new_user, 'custom_field_'.$value['id'], $upFile );
361 $pictureUpload = 'yes';
362 }
363 }
364 }
365 break;
366 }
367 case "avatar":{
368
369 $uploadedfile = $value['item_type'].$value['id'];
370 $target_path_original = "wp-content/uploads/profile_builder/avatars/";
371 $fileName = $_FILES[$uploadedfile]['name'];
372 $finalFileName = '';
373
374 for ($i=0; $i < strlen($fileName); $i++){
375 if ($fileName[$i] == "'")
376 $finalFileName .= '`';
377 elseif ($fileName[$i] == ' ')
378 $finalFileName .= '_';
379 else $finalFileName .= $fileName[$i];
380 }
381
382 $fileName = $finalFileName;
383
384 $target_path = $target_path_original . 'userID_'.$new_user.'_originalAvatar_'. $fileName;
385
386 /* when trying to upload file, be sure it's one of the accepted image file-types */
387 if ( (($_FILES[$uploadedfile]['type'] == 'image/jpeg') || ($_FILES[$uploadedfile]['type'] == 'image/jpg') || ($_FILES[$uploadedfile]['type'] == 'image/png') || ($_FILES[$uploadedfile]['type'] == 'image/bmp') || ($_FILES[$uploadedfile]['type'] == 'image/pjpeg') || ($_FILES[$uploadedfile]['type'] == 'image/x-png')) && (($_FILES[$uploadedfile]['size'] < ServerMaxUploadSizeByte) && ($_FILES[$uploadedfile]['size'] !=0)) ){
388 $wp_filetype = wp_check_filetype(basename( $_FILES[$uploadedfile]['name']), null );
389 $attachment = array('post_mime_type' => $wp_filetype['type'],
390 'post_title' => $fileName, //preg_replace('/\.[^.]+$/', '', basename($_FILES[$uploadedfile]['name'])),
391 'post_content' => '',
392 'post_status' => 'inherit'
393 );
394
395
396 $attach_id = wp_insert_attachment( $attachment, $target_path);
397
398 $upFile = image_downsize( $attach_id, 'thumbnail' );
399 $upFile = $upFile[0];
400
401 //if file upload succeded
402 if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)){
403 add_user_meta( $new_user, 'custom_field_'.$value['id'], $upFile );
404 $avatarUpload = 'yes';
405 }
406 else $avatarUpload = 'no';
407 }
408 if (($_FILES[$uploadedfile]['type'] == ''))
409 $avatarUpload = 'yes';
410
411 break;
412 }
413 }
414 }
415 }
416
417
418 //send an email to the admin regarding each and every new subscriber
419 $bloginfo = get_bloginfo( 'name' );
420 $registerFilterArray['adminMessageOnRegistration'] = '';
421 $registerFilterArray['adminMessageOnRegistration'] = __('New subscriber on', 'profilebuilder') .' '.$bloginfo . "\r\n\r\n";
422 $registerFilterArray['adminMessageOnRegistration'] .= __('Username', 'profilebuilder') .': '. esc_attr($_POST['user_name']) . "\r\n";
423 $registerFilterArray['adminMessageOnRegistration'] .= __('E-mail', 'profilebuilder') .': '. esc_attr($_POST['email']) . "\r\n";
424 $registerFilterArray['adminMessageOnRegistration'] = apply_filters('wppb_register_admin_message_content', $registerFilterArray['adminMessageOnRegistration']);
425
426 $registerFilterArray['adminMessageOnRegistrationTitle'] = '['. $bloginfo .']'. __('A new subscriber has (been) registered!');
427 $registerFilterArray['adminMessageOnRegistrationTitle'] = apply_filters ('wppb_register_admin_message_title', $registerFilterArray['adminMessageOnRegistrationTitle']);
428
429 if (trim($registerFilterArray['adminMessageOnRegistration']) != '')
430 wp_mail(get_option('admin_email'), $registerFilterArray['adminMessageOnRegistrationTitle'], $registerFilterArray['adminMessageOnRegistration']);
431
432
433 //send an email to the newly registered user, if this option was selected
434 if (isset($_POST['send_credentials_via_email']) && ($_POST['send_credentials_via_email'] == 'sending')){
435 //change these variables to modify sent email message, destination and source.
436 $email = $_POST['email'];
437 $mailPassword = $_POST['passw1'];
438 $mailUsername = $_POST['user_name'];
439
440 $registerFilterArray['userMessageFrom'] = get_bloginfo('name');
441 $registerFilterArray['userMessageFrom'] = apply_filters('wppb_register_from_email_content', $registerFilterArray['userMessageFrom']);
442
443 $registerFilterArray['userMessageSubject'] = 'A new account has been created for you.';
444 $registerFilterArray['userMessageSubject'] = apply_filters('wppb_register_subject_email_content', $registerFilterArray['userMessageSubject']);
445
446 $registerFilterArray['userMessageContent'] = 'Welcome to blog '.$registerFilterArray['userMessageFrom'].'. Your username is:'.$mailUsername.' and password:'.$mailPassword;
447 $registerFilterArray['userMessageContent'] = apply_filters('wppb_register_email_content', $registerFilterArray['userMessageContent']);
448
449 $messageSent = wp_mail( $email, $registerFilterArray['userMessageSubject'], $registerFilterArray['userMessageContent']);
450 if( $messageSent == TRUE)
451 $sentEmailStatus = 2;
452 else
453 $sentEmailStatus = 1;
454 }
455
456 }
457 }
458
459 ?>
460 <div class="wppb_holder" id="wppb_register">
461 <?php
462 if ( is_user_logged_in() && !current_user_can( 'create_users' ) ) :
463
464 global $user_ID;
465 $login = get_userdata( $user_ID );
466 if($login->display_name == ''){
467 $login->display_name = $login->user_login;
468 }
469 $registerFilterArray['loginLogoutError'] = '
470 <p class="log-in-out alert">'. __('You are logged in as', 'profilebuilder') .' <a href="'.get_author_posts_url( $login->ID ).'" title="'.$login->display_name.'">'.$login->display_name.'</a>. '. __('You don\'t need another account.', 'profilebuilder') .' <a href="'.wp_logout_url(get_permalink()).'" title="'. __('Log out of this account.', 'profilebuilder') .'">'. __('Logout', 'profilebuilder') .' &raquo;</a></p><!-- .log-in-out .alert -->';
471 $registerFilterArray['loginLogoutError'] = apply_filters('wppb_register_have_account_alert', $registerFilterArray['loginLogoutError']);
472 echo $registerFilterArray['loginLogoutError'];
473
474 elseif ( $new_user != 'no' ) :
475 if ( current_user_can( 'create_users' ) ){
476 $registerFilterArray['registrationMessage1'] = '
477 <p class="success">'. __('A user account has been created for', 'profilebuilder') .' '. $registered_name. '.</p><!-- .success -->';
478 $registerFilterArray['registrationMessage1'] = apply_filters('wppb_register_account_created1', $registerFilterArray['registrationMessage1']);
479 echo $registerFilterArray['registrationMessage1'];
480
481 $wppb_addons = wppb_plugin_dir . '/premium/addon/';
482 if (file_exists ( $wppb_addons.'addon.php' )){
483 //check to see if the redirecting addon is present and activated
484 $wppb_premium_addon_settings = get_option('wppb_premium_addon_settings');
485 if ($wppb_premium_addon_settings['customRedirect'] == 'show'){
486 //check to see if the redirect location is not an empty string and is activated
487 $customRedirectSettings = get_option('customRedirectSettings');
488 if ((trim($customRedirectSettings['afterRegisterTarget']) != '') && ($customRedirectSettings['afterRegister'] == 'yes')){
489 $redirectLink = trim($customRedirectSettings['afterRegisterTarget']);
490 $findHttp = strpos($redirectLink, 'http');
491 if ($findHttp === false)
492 $redirectLink = 'http://'. $redirectLink;
493 }
494 }
495 }
496 $registerFilterArray['redirectMessage1'] = '<font color="black">You will soon be redirected automatically. If you see this page for more than 3 second, please click <a href="'.$redirectLink.'">here</a>.<meta http-equiv="Refresh" content="3;url='.$redirectLink.'" /></font><br/><br/>';
497 $registerFilterArray['redirectMessage1'] = apply_filters('wppb_register_redirect_after_creation1', $registerFilterArray['redirectMessage1']);
498 echo $registerFilterArray['redirectMessage1'];
499
500 }else{
501 $registerFilterArray['registrationMessage2'] = '
502 <p class="success">'. __('Thank you for registering', 'profilebuilder') .' '. $registered_name .'.</p><!-- .success -->';
503 $registerFilterArray['registrationMessage2'] = apply_filters('wppb_register_account_created2', $registerFilterArray['registrationMessage2']);
504 echo $registerFilterArray['registrationMessage2'];
505
506 $wppb_addons = wppb_plugin_dir . '/premium/addon/';
507 if (file_exists ( $wppb_addons.'addon.php' )){
508 //check to see if the redirecting addon is present and activated
509 $wppb_premium_addon_settings = get_option('wppb_premium_addon_settings');
510 if ($wppb_premium_addon_settings['customRedirect'] == 'show'){
511 //check to see if the redirect location is not an empty string and is activated
512 $customRedirectSettings = get_option('customRedirectSettings');
513 if ((trim($customRedirectSettings['afterRegisterTarget']) != '') && ($customRedirectSettings['afterRegister'] == 'yes')){
514 $redirectLink = trim($customRedirectSettings['afterRegisterTarget']);
515 $findHttp = strpos($redirectLink, 'http');
516 if ($findHttp === false)
517 $redirectLink = 'http://'. $redirectLink;
518 }
519 }
520 }
521 $registerFilterArray['redirectMessage2'] = '<font color="black">You will soon be redirected automatically. If you see this page for more than 3 second, please click <a href="'.$redirectLink.'">here</a>.<meta http-equiv="Refresh" content="3;url='.$redirectLink.'" /></font><br/><br/>';
522 $registerFilterArray['redirectMessage2'] = apply_filters('wppb_register_redirect_after_creation2', $registerFilterArray['redirectMessage2']);
523 echo $registerFilterArray['redirectMessage2'];
524 }
525
526
527 if(isset($_POST['send_credentials_via_email'])){
528 if ($sentEmailStatus == 1){
529 $registerFilterArray['emailMessage1'] = '<p class="error">'. __('An error occured while trying to send the notification email.', 'profilebuilder') .'</p><!-- .error -->';
530 $registerFilterArray['emailMessage1'] = apply_filters('wppb_register_send_notification_email_fail', $registerFilterArray['emailMessage1']);
531 echo $registerFilterArray['emailMessage1'];
532 }elseif ($sentEmailStatus == 2){
533 $registerFilterArray['emailMessage2'] = '<p class="success">'. __('An email containing the username and password was successfully sent.', 'profilebuilder') .'</p><!-- .success -->';
534 $registerFilterArray['emailMessage2'] = apply_filters('wppb_register_send_notification_email_success', $registerFilterArray['emailMessage2']);
535 echo $registerFilterArray['emailMessage2'];
536 }
537 }
538 ?>
539 <?php
540 else :
541 if ( $error ) :
542 $registerFilterArray['errorMessage'] = '<p class="error">'. $error .'</p><!-- .error -->';
543 $registerFilterArray['errorMessage'] = apply_filters('wppb_register_error_messaging', $registerFilterArray['errorMessage']);
544 echo $registerFilterArray['errorMessage'];
545 endif;
546
547 if ( current_user_can( 'create_users' ) && $registration ) :
548 $registerFilterArray['alertMessage1'] = '<p class="alert">'. __('Users can register themselves or you can manually create users here.', 'profilebuilder') .'</p><!-- .alert -->';
549 $registerFilterArray['alertMessage1'] = apply_filters('wppb_register_alert_messaging1', $registerFilterArray['alertMessage1']);
550 echo $registerFilterArray['alertMessage1'];
551
552 elseif ( current_user_can( 'create_users' ) ) :
553 $registerFilterArray['alertMessage2'] = '<p class="alert">'. __('Users cannot currently register themselves, but you can manually create users here.', 'profilebuilder') .'</p><!-- .alert -->';
554 $registerFilterArray['alertMessage2'] = apply_filters('wppb_register_alert_messaging2', $registerFilterArray['alertMessage2']);
555 echo $registerFilterArray['alertMessage2'];
556
557 elseif ( !current_user_can( 'create_users' ) && !$registration) :
558 $registerFilterArray['alertMessage3'] = '<p class="alert">'. __('Only an administrator can add new users.', 'profilebuilder') .'</p><!-- .alert -->';
559 $registerFilterArray['alertMessage3'] = apply_filters('wppb_register_alert_messaging3', $registerFilterArray['alertMessage3']);
560 echo $registerFilterArray['alertMessage3'];
561 endif;
562
563 if ( $registration || current_user_can( 'create_users' ) ) :
564 /* use this action hook to add extra content before the register form. */
565 do_action( 'wppb_before_register_fields' );
566 ?>
567 <form enctype="multipart/form-data" method="post" id="adduser" class="user-forms" action="http://<?php echo $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>">
568 <?php
569 echo '<input type="hidden" name="MAX_FILE_SIZE" value="'.ServerMaxUploadSizeByte.'" /><!-- set the MAX_FILE_SIZE to the server\'s current max upload size in bytes -->';
570
571 $registerFilterArray['name1'] = '<p class="registerNameHeading"><strong>'. __('Name', 'profilebuilder') .'</strong></p>';
572 $registerFilterArray['name1'] = apply_filters('wppb_register_content_name1', $registerFilterArray['name1']);
573 echo $registerFilterArray['name1'];
574
575 if ($wppb_defaultOptions['username'] == 'show'){
576 $errorMark = '';
577 if ($wppb_defaultOptions['usernameRequired'] == 'yes'){
578 $errorMark = '<font color="red" title="This field is required for registration.">*</font>';
579 }
580
581 $registerFilterArray['name2'] = '
582 <p class="form-username">
583 <label for="user_name">'. __('Username', 'profilebuilder') .$errorMark.'</label>
584 <input class="text-input" name="user_name" type="text" id="user_name" value="'.trim($_POST['user_name']).'" />
585 <span class="wppb-description-delimiter">'. __('(required)', 'profilebuilder') .'</span>
586 </p><!-- .form-username -->';
587 $registerFilterArray['name2'] = apply_filters('wppb_register_content_name2', $registerFilterArray['name2']);
588 echo $registerFilterArray['name2'];
589 }
590
591 if ($wppb_defaultOptions['firstname'] == 'show'){
592 $errorVar = '';
593 $errorMark = '';
594 if ($wppb_defaultOptions['firstnameRequired'] == 'yes'){
595 $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
596 if ((trim($_POST['first_name']) == '') && isset($_POST['first_name'])){
597 $errorMark = '<img src="'.wppb_plugin_url . '/assets/images/pencil_delete.png" title="This field must be filled out before registering (It was marked as required by the administrator)."/>';
598 $errorVar = ' errorHolder';
599 }
600 }
601
602 $registerFilterArray['name3'] = '
603 <p class="first_name'.$errorVar.'">
604 <label for="first_name">'. __('First Name', 'profilebuilder') .$errorMark.'</label>
605 <input class="text-input" name="first_name" type="text" id="first_name" value="'.trim($_POST['first_name']).'" />
606 </p><!-- .first_name -->';
607 $registerFilterArray['name3'] = apply_filters('wppb_register_content_name3', $registerFilterArray['name3']);
608 echo $registerFilterArray['name3'];
609 }
610
611 if ($wppb_defaultOptions['lastname'] == 'show'){
612 $errorVar = '';
613 $errorMark = '';
614 if ($wppb_defaultOptions['lastnameRequired'] == 'yes'){
615 $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
616 if ((trim($_POST['last_name']) == '') && isset($_POST['last_name'])){
617 $errorMark = '<img src="'.wppb_plugin_url . '/assets/images/pencil_delete.png" title="This field must be filled out before registering (It was marked as required by the administrator)."/>';
618 $errorVar = ' errorHolder';
619 }
620 }
621
622 $registerFilterArray['name4'] = '
623 <p class="last_name'.$errorVar.'">
624 <label for="last_name">'. __('Last Name', 'profilebuilder') .$errorMark.'</label>
625 <input class="text-input" name="last_name" type="text" id="last_name" value="'.trim($_POST['last_name']).'" />
626 </p><!-- .last_name -->';
627 $registerFilterArray['name4'] = apply_filters('wppb_register_content_name4', $registerFilterArray['name4']);
628 echo $registerFilterArray['name4'];
629 }
630
631 if ($wppb_defaultOptions['nickname'] == 'show'){
632 $errorVar = '';
633 $errorMark = '';
634 if ($wppb_defaultOptions['nicknameRequired'] == 'yes'){
635 $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
636 if ((trim($_POST['nickname']) == '') && isset($_POST['nickname'])){
637 $errorMark = '<img src="'.wppb_plugin_url . '/assets/images/pencil_delete.png" title="This field must be filled out before registering (It was marked as required by the administrator)."/>';
638 $errorVar = ' errorHolder';
639 }
640 }
641
642 $registerFilterArray['name5'] = '
643 <p class="nickname'.$errorVar.'">
644 <label for="nickname">'. __('Nickname', 'profilebuilder') .$errorMark.'</label>
645 <input class="text-input" name="nickname" type="text" id="nickname" value="'.trim($_POST['nickname']).'" />
646 </p><!-- .nickname -->';
647 $registerFilterArray['name5'] = apply_filters('wppb_register_content_name5', $registerFilterArray['name5']);
648 echo $registerFilterArray['name5'];
649 }
650
651 $registerFilterArray['info1'] = '<p register="registerContactInfoHeading"><strong>'. __('Contact Info', 'profilebuilder') .'</strong></p>';
652 $registerFilterArray['info1'] = apply_filters('wppb_register_content_info1', $registerFilterArray['info1']);
653 echo $registerFilterArray['info1'];
654
655 if ($wppb_defaultOptions['email'] == 'show'){
656 $errorVar = '';
657 $errorMark = '';
658 if ($wppb_defaultOptions['emailRequired'] == 'yes'){
659 $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
660 if ((trim($_POST['email']) == '') && isset($_POST['email']))
661 $errorMark = '<img src="'.wppb_plugin_url . '/assets/images/pencil_delete.png" title="This field is required for registration."/>';
662 }
663
664 $registerFilterArray['info2'] = '
665 <p class="form-email">
666 <label for="email">'. __('E-mail', 'profilebuilder') .$errorMark.'</label>
667 <input class="text-input" name="email" type="text" id="email" value="'.trim($_POST['email']).'" />
668 <span class="wppb-description-delimiter">'. __('(required)', 'profilebuilder') .'</span>
669 </p><!-- .form-email -->';
670 $registerFilterArray['info2'] = apply_filters('wppb_register_content_info2', $registerFilterArray['info2']);
671 echo $registerFilterArray['info2'];
672 }
673
674 if ($wppb_defaultOptions['website'] == 'show'){
675 $errorVar = '';
676 $errorMark = '';
677 if ($wppb_defaultOptions['websiteRequired'] == 'yes'){
678 $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
679 if ((trim($_POST['website']) == '') && isset($_POST['website'])){
680 $errorMark = '<img src="'.wppb_plugin_url . '/assets/images/pencil_delete.png" title="This field must be filled out before registering (It was marked as required by the administrator)."/>';
681 $errorVar = ' errorHolder';
682 }
683 }
684
685 $registerFilterArray['info3'] = '
686 <p class="form-website'.$errorVar.'">
687 <label for="website">'. __('Website', 'profilebuilder') .$errorMark.'</label>
688 <input class="text-input" name="website" type="text" id="website" value="'.trim($_POST['website']).'" />
689 </p><!-- .form-website -->';
690 $registerFilterArray['info3'] = apply_filters('wppb_register_content_info3', $registerFilterArray['info3']);
691 echo $registerFilterArray['info3'];
692 }
693
694 if ($wppb_defaultOptions['aim'] == 'show'){
695 $errorVar = '';
696 $errorMark = '';
697 if ($wppb_defaultOptions['aimRequired'] == 'yes'){
698 $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
699 if ((trim($_POST['aim']) == '') && isset($_POST['aim'])){
700 $errorMark = '<img src="'.wppb_plugin_url . '/assets/images/pencil_delete.png" title="This field must be filled out before registering (It was marked as required by the administrator)."/>';
701 $errorVar = ' errorHolder';
702 }
703 }
704
705 $registerFilterArray['info4'] = '
706 <p class="form-aim'.$errorVar.'">
707 <label for="aim">'. __('AIM', 'profilebuilder') .$errorMark.'</label>
708 <input class="text-input" name="aim" type="text" id="aim" value="'.trim($_POST['aim']).'" />
709 </p><!-- .form-aim -->';
710 $registerFilterArray['info4'] = apply_filters('wppb_register_content_info4', $registerFilterArray['info4']);
711 echo $registerFilterArray['info4'];
712 }
713
714 if ($wppb_defaultOptions['yahoo'] == 'show'){
715 $errorVar = '';
716 $errorMark = '';
717 if ($wppb_defaultOptions['yahooRequired'] == 'yes'){
718 $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
719 if ((trim($_POST['yim']) == '') && isset($_POST['yim'])){
720 $errorMark = '<img src="'.wppb_plugin_url . '/assets/images/pencil_delete.png" title="This field must be filled out before registering (It was marked as required by the administrator)."/>';
721 $errorVar = ' errorHolder';
722 }
723 }
724
725 $registerFilterArray['info5'] = '
726 <p class="form-yim'.$errorVar.'">
727 <label for="yim">'. __('Yahoo IM', 'profilebuilder') .$errorMark.'</label>
728 <input class="text-input" name="yim" type="text" id="yim" value="'.trim($_POST['yim']).'" />
729 </p><!-- .form-yim -->';
730 $registerFilterArray['info5'] = apply_filters('wppb_register_content_info5', $registerFilterArray['info5']);
731 echo $registerFilterArray['info5'];
732 }
733
734 if ($wppb_defaultOptions['jabber'] == 'show'){
735 $errorVar = '';
736 $errorMark = '';
737 if ($wppb_defaultOptions['jabberRequired'] == 'yes'){
738 $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
739 if ((trim($_POST['jabber']) == '') && isset($_POST['jabber'])){
740 $errorMark = '<img src="'.wppb_plugin_url . '/assets/images/pencil_delete.png" title="This field must be filled out before registering (It was marked as required by the administrator)."/>';
741 $errorVar = ' errorHolder';
742 }
743 }
744
745 $registerFilterArray['info6'] = '
746 <p class="form-jabber'.$errorVar.'">
747 <label for="jabber">'. __('Jabber / Google Talk', 'profilebuilder') .$errorMark.'</label>
748 <input class="text-input" name="jabber" type="text" id="jabber" value="'.trim($_POST['jabber']).'" />
749 </p><!-- .form-jabber -->';
750 $registerFilterArray['info6'] = apply_filters('wppb_register_content_info6', $registerFilterArray['info6']);
751 echo $registerFilterArray['info6'];
752 }
753
754 $registerFilterArray['ay1'] = '<p class="registerAboutYourselfHeader"><strong>'. __('About Yourself', 'profilebuilder') .'</strong></p>';
755 $registerFilterArray['ay1'] = apply_filters('wppb_register_content_about_yourself1', $registerFilterArray['ay1']);
756 echo $registerFilterArray['ay1'];
757
758 if ($wppb_defaultOptions['bio'] == 'show'){
759 $errorVar = '';
760 $errorMark = '';
761 if ($wppb_defaultOptions['bioRequired'] == 'yes'){
762 $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
763 if ((trim($_POST['description']) == '') && isset($_POST['description'])){
764 $errorMark = '<img src="'.wppb_plugin_url . '/assets/images/pencil_delete.png" title="This field must be filled out before registering (It was marked as required by the administrator)."/>';
765 $errorVar = ' errorHolder';
766 }
767 }
768
769 $registerFilterArray['ay2'] = '
770 <p class="form-description'.$errorVar.'">
771 <label for="description">'. __('Biographical Info', 'profilebuilder') .$errorMark.'</label>
772 <textarea class="text-input" name="description" id="description" rows="5" cols="30">'.trim($_POST['description']).'</textarea>
773 </p><!-- .form-description -->';
774 $registerFilterArray['ay2'] = apply_filters('wppb_register_content_about_yourself2', $registerFilterArray['ay2']);
775 echo $registerFilterArray['ay2'];
776 }
777
778 if ($wppb_defaultOptions['password'] == 'show'){
779 $errorMark = '';
780 if ($wppb_defaultOptions['passwordRequired'] == 'yes'){
781 $errorMark = '<font color="red" title="This field is required for registration.">*</font>';
782 }
783
784 $registerFilterArray['ay3'] = '
785 <p class="form-password">
786 <label for="pass1">'. __('Password', 'profilebuilder') .$errorMark.'</label>
787 <input class="text-input" name="passw1" type="password" id="pass1" value="'.trim($_POST['passw1']).'" />
788 </p><!-- .form-password -->
789
790 <p class="form-password">
791 <label for="pass2">'. __('Repeat Password', 'profilebuilder') .$errorMark.'</label>
792 <input class="text-input" name="passw2" type="password" id="pass2" value="'.trim($_POST['passw2']).'" />
793 </p><!-- .form-password -->';
794 $registerFilterArray['ay3'] = apply_filters('wppb_register_content_about_yourself3', $registerFilterArray['ay3']);
795 echo $registerFilterArray['ay3'];
796 }
797
798 $wppb_premium = wppb_plugin_dir . '/premium/functions/';
799 if (file_exists ( $wppb_premium.'extra.fields.php' )){
800 require_once($wppb_premium.'extra.fields.php');
801 register_user_extra_fields($error, $_POST, $extraFieldsErrorHolder);
802 }
803
804 if (isset($_POST['send_credentials_via_email']))
805 $checkedVar = ' checked';
806 else $checkedVar = '';
807 $registerFilterArray['confirmationEmailForm'] = '
808 <p class="send-confirmation-email">
809 <label for="send-confirmation-email">
810 <input id="send_credentials_via_email" type="checkbox" name="send_credentials_via_email" value="sending"'. $checkedVar .'/>
811 <span class="wppb-description-delimiter"> '. __('Send these credentials via email.', 'profilebuilder') .'</span>
812 </label>
813 </p><!-- .send-confirmation-email -->';
814 $registerFilterArray['confirmationEmailForm'] = apply_filters('wppb_register_confirmation_email_form', $registerFilterArray['confirmationEmailForm']);
815 echo $registerFilterArray['confirmationEmailForm'];
816 ?>
817
818 <p class="form-submit">
819 <input name="adduser" type="submit" id="addusersub" class="submit button" value="<?php if ( current_user_can( 'create_users' ) ) _e('Add User', 'profilebuilder'); else _e('Register', 'profilebuilder'); ?>" />
820 <input name="action" type="hidden" id="action" value="adduser" />
821 </p><!-- .form-submit -->
822 <?php
823 wp_nonce_field('verify_true_registration','register_nonce_field');
824 ?>
825 </form><!-- #adduser -->
826
827 <?php
828 endif;
829 endif;
830
831 /* use this action hook to add extra content after the register form. */
832 do_action( 'wppb_after_register_fields' );
833 ?>
834
835 </div>
836 <?php
837 $output = ob_get_contents();
838 ob_end_clean();
839
840 $registerFilterArray = apply_filters('wppb_register', $registerFilterArray);
841
842 return $output;
843 }
844 ?>