User registration & user profile – Profile Builder - Version 1.1.15

Version Description

Minor changes in the index file.

Download this release

Release Info

Developer barinagabriel
Plugin Icon 128x128 User registration & user profile – Profile Builder
Version 1.1.15
Comparing to
See all releases

Code changes from version 1.1.14 to 1.1.15

front-end/wppb.edit.profile.php CHANGED
@@ -1,963 +1,989 @@
1
- <?php
2
- /*
3
- wp_update_user only attempts to clear and reset cookies if it's updating the password.
4
- The php function setcookie(), used in both the cookie-clearing and cookie-resetting functions,
5
- adds to the page headers and therefore must be called within the first php tag on the page, and
6
- before the WordPress get_header() function. Since wp_update_user needs this, it must be at the
7
- beginning of the page as well.
8
- */
9
- $changesSaved = 'no';
10
- $changesSavedNoMatchingPass = 'no';
11
- $changesSavedNoPass = 'no';
12
-
13
- function wppb_save_the_password(){
14
- global $changesSaved;
15
- global $changesSavedNoMatchingPass;
16
- global $changesSavedNoPass;
17
-
18
- /* Load registration file if the version number is less then 3.1. */
19
- $versionNo = get_bloginfo( 'version' );
20
- if ($versionNo <= '3.1')
21
- require_once(ABSPATH . WPINC . '/registration.php');
22
- /* Get user info. */
23
- global $current_user;
24
-
25
- if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'update-user' && wp_verify_nonce($_POST['edit_nonce_field'],'verify_edit_user') ) {
26
- /* Update user password. */
27
- if ( !empty($_POST['pass1'] ) && !empty( $_POST['pass2'] ) ) {
28
- if ( $_POST['pass1'] == $_POST['pass2'] )
29
- {
30
- wp_update_user( array( 'ID' => $current_user->id, 'user_pass' => esc_attr( $_POST['pass1'] ) ) );
31
- $changesSaved = 'yes';
32
- } else {
33
- $changesSavedNoMatchingPass = 'yes';
34
- }
35
- }elseif (( empty($_POST['pass1'] ) && !empty( $_POST['pass2'] )) || ( !empty($_POST['pass1'] ) && empty( $_POST['pass2'] )) ) {
36
- $changesSavedNoPass = 'yes';
37
- }
38
- }
39
- }
40
- add_action('init', 'wppb_save_the_password');
41
-
42
- function wppb_front_end_profile_info() {
43
-
44
- global $changesSaved;
45
- global $changesSavedNoMatchingPass;
46
- global $changesSavedNoPass;
47
- $editProfileFilterArray = array();
48
- $extraFieldsErrorHolder = array(); //we will use this array to store the ID's of the extra-fields left uncompleted
49
-
50
- ob_start();
51
- get_currentuserinfo();
52
- $wppb_defaultOptions = get_option('wppb_default_settings');
53
- $changesSavedNoEmail = 'no';
54
- $changesSavedNoEmailExist = 'no';
55
- $previousError = 'no';
56
- $pictureUpload = 'no';
57
- $avatarUpload = 'yes';
58
- $allRequiredCompleted = 'yes';
59
- $uploadName = array();
60
- $uploadSize = array();
61
- $editFilterArray = array();
62
-
63
-
64
- /* Load registration file if the version number is less then 3.1. */
65
- $versionNo = get_bloginfo( 'version' );
66
- if ($versionNo <= '3.1')
67
- require_once(ABSPATH . WPINC . '/registration.php');
68
- /* Get user info. */
69
- global $current_user;
70
-
71
- /* delete the attachment if set */
72
- if (isset($_GET['userID']) && isset($_GET['field'])){
73
- update_user_meta( $_GET['userID'], $_GET['field'], '');
74
- }
75
- /* delete the avatar */
76
- if (isset($_GET['userID']) && isset($_GET['fieldOriginal']) && isset($_GET['fieldResized'])){
77
- update_user_meta( $_GET['userID'], $_GET['fieldOriginal'], '');
78
- update_user_meta( $_GET['userID'], $_GET['fieldResized'], '');
79
- }
80
-
81
- //fallback if the file was largen then post_max_size, case in which no errors can be saved in $_FILES[fileName]['error']
82
- if (empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
83
- $editProfileFilterArray['noPost'] = '
84
- <p class="error">'.
85
- __('The information size you were trying to submit was larger than', 'profilebuilder') .' '. ServerMaxUploadSizeMega .'b!<br/>'.
86
- __('This is usually caused by a large file(s) trying to be uploaded.', 'profilebuilder') .'<br/>'.
87
- __('Since it was also larger than', 'profilebuilder') .' '. ServerMaxPostSizeMega .'b '. __('no additional information is available.', 'profilebuilder') .'<br/>
88
- </p>';
89
- $editProfileFilterArray['noPost'] = apply_filters('wppb_edit_profile_no_post_error', $editProfileFilterArray['noPost']);
90
- echo $editProfileFilterArray['noPost'];
91
- }
92
- // a way to catch the user before updating his/her profile without completing a required field
93
- if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'update-user' && wp_verify_nonce($_POST['edit_nonce_field'],'verify_edit_user') ) {
94
- //variable to control whether the user submitted data or not
95
-
96
- $allRequiredCompleted = apply_filters('wppb_edit_profile_all_required_completed', $allRequiredCompleted);
97
- }
98
-
99
- /* If profile was saved, update profile. */
100
- if ( ('POST' == $_SERVER['REQUEST_METHOD']) && (!empty( $_POST['action'] )) && ($_POST['action'] == 'update-user') && (wp_verify_nonce($_POST['edit_nonce_field'],'verify_edit_user')) && ($allRequiredCompleted == 'yes') ) {
101
-
102
- $_POST['email'] = apply_filters('wppb_edit_profile_posted_email', $_POST['email']);
103
- if ($wppb_defaultOptions['emailRequired'] == 'yes'){
104
- if ((trim($_POST['email']) != '') && isset($_POST['email'])){
105
- if (email_exists( $_POST['email'] ) != FALSE)
106
- $thisEmail = email_exists( $_POST['email'] );
107
- else $thisEmail = $current_user->id;
108
-
109
- if ( !empty( $_POST['email'] ) && is_email( $_POST['email'] )){ // if the user entered a valid email address
110
- if (($thisEmail == $current_user->id)){ // if the entered email address is not already registered to some other user
111
- wp_update_user( array( 'ID' => $current_user->id, 'user_email' => esc_attr( $_POST['email'] )));
112
- $changesSaved = 'yes';
113
- }else{
114
- $changesSavedNoEmailExist = 'yes';
115
- }
116
- }else{
117
- $changesSavedNoEmail = 'yes';
118
- }
119
- }
120
- }else{
121
- if (email_exists( $_POST['email'] ) != FALSE)
122
- $thisEmail = email_exists( $_POST['email'] );
123
- else $thisEmail = $current_user->id;
124
-
125
- if ( !empty( $_POST['email'] ) && is_email( $_POST['email'] )){ // if the user entered a valid email address
126
- if (($thisEmail == $current_user->id)){ // if the entered email address is not already registered to some other user
127
- wp_update_user( array( 'ID' => $current_user->id, 'user_email' => esc_attr( $_POST['email'] )));
128
- $changesSaved = 'yes';
129
- }else{
130
- $changesSavedNoEmailExist = 'yes';
131
- }
132
- }else{
133
- $changesSavedNoEmail = 'yes';
134
- }
135
- }
136
-
137
-
138
- /* Update user information. */
139
- if ($wppb_defaultOptions['firstname'] == 'show'){
140
- $_POST['first_name'] = apply_filters('wppb_edit_profile_posted_first_name', $_POST['first_name']);
141
- if ($wppb_defaultOptions['firstnameRequired'] == 'yes'){
142
- if ((trim($_POST['first_name']) != '') && isset($_POST['first_name'])){
143
- wp_update_user( array( 'ID' => $current_user->id, 'first_name' => esc_attr( $_POST['first_name'] )));
144
- $changesSaved = 'yes';
145
- }
146
- }else{
147
- wp_update_user( array( 'ID' => $current_user->id, 'first_name' => esc_attr( $_POST['first_name'] )));
148
- $changesSaved = 'yes';
149
- }
150
- }
151
-
152
- if ($wppb_defaultOptions['lastname'] == 'show'){
153
- $_POST['last_name'] = apply_filters('wppb_edit_profile_posted_last_name', $_POST['last_name']);
154
- if ($wppb_defaultOptions['lastnameRequired'] == 'yes'){
155
- if ((trim($_POST['last_name']) != '') && isset($_POST['last_name'])){
156
- wp_update_user( array( 'ID' => $current_user->id, 'last_name' => esc_attr( $_POST['last_name'] )));
157
- $changesSaved = 'yes';
158
- }
159
- }else{
160
- wp_update_user( array( 'ID' => $current_user->id, 'last_name' => esc_attr( $_POST['last_name'] )));
161
- $changesSaved = 'yes';
162
- }
163
- }
164
-
165
- if ($wppb_defaultOptions['nickname'] == 'show'){
166
- $_POST['nickname'] = apply_filters('wppb_edit_profile_posted_nickname', $_POST['nickname']);
167
- if ($wppb_defaultOptions['nicknameRequired'] == 'yes'){
168
- if ((trim($_POST['nickname']) != '') && isset($_POST['nickname'])){
169
- wp_update_user( array( 'ID' => $current_user->id, 'nickname' => esc_attr( $_POST['nickname'] )));
170
- $changesSaved = 'yes';
171
- }
172
- }else{
173
- wp_update_user( array( 'ID' => $current_user->id, 'nickname' => esc_attr( $_POST['nickname'] )));
174
- $changesSaved = 'yes';
175
- }
176
-
177
- }
178
-
179
- if ($wppb_defaultOptions['dispname'] == 'show'){
180
- $_POST['display_name'] = apply_filters('wppb_edit_profile_posted_display_name', $_POST['display_name']);
181
- if ($wppb_defaultOptions['dispnameRequired'] == 'yes'){
182
- if ((trim($_POST['display_name']) != '') && isset($_POST['display_name'])){
183
- wp_update_user( array( 'ID' => $current_user->id, 'display_name' => esc_attr( $_POST['display_name'] )));
184
- $changesSaved = 'yes';
185
- }
186
- }else{
187
- wp_update_user( array( 'ID' => $current_user->id, 'display_name' => esc_attr( $_POST['display_name'] )));
188
- $changesSaved = 'yes';
189
- }
190
- }
191
-
192
- if ($wppb_defaultOptions['website'] == 'show'){
193
- $_POST['website'] = apply_filters('wppb_edit_profile_posted_website', $_POST['website']);
194
- if ($wppb_defaultOptions['websiteRequired'] == 'yes'){
195
- if ((trim($_POST['website']) != '') && isset($_POST['website'])){
196
- $wppbPos = strpos($_POST['website'], 'http://');
197
- if($wppbPos !== FALSE){
198
- wp_update_user( array( 'ID' => $current_user->id, 'user_url' => esc_attr( $_POST['website'] )));
199
- $changesSaved = 'yes';
200
- }else{
201
- wp_update_user( array( 'ID' => $current_user->id, 'user_url' => 'http://'.esc_attr( $_POST['website'] )));
202
- $changesSaved = 'yes';
203
- }
204
- }
205
- }else{
206
- $wppbPos = strpos($_POST['website'], 'http://');
207
- $website = esc_attr( $_POST['website'] );
208
- if($wppbPos !== FALSE){
209
- if ($website == 'http://')
210
- $website = '';
211
- wp_update_user( array( 'ID' => $current_user->id, 'user_url' => $website));
212
- $changesSaved = 'yes';
213
- }else{
214
- if ($website != '')
215
- $website = 'http://'.$website;
216
- wp_update_user( array( 'ID' => $current_user->id, 'user_url' => $website));
217
- $changesSaved = 'yes';
218
- }
219
- }
220
- }
221
-
222
- if ($wppb_defaultOptions['aim'] == 'show'){
223
- $_POST['aim'] = apply_filters('wppb_edit_profile_posted_aim', $_POST['aim']);
224
- if ($wppb_defaultOptions['aimRequired'] == 'yes'){
225
- if ((trim($_POST['aim']) != '') && isset($_POST['aim'])){
226
- update_user_meta( $current_user->id, 'aim', esc_attr( $_POST['aim'] ) );
227
- $changesSaved = 'yes';
228
- }
229
- }else{
230
- update_user_meta( $current_user->id, 'aim', esc_attr( $_POST['aim'] ) );
231
- $changesSaved = 'yes';
232
- }
233
- }
234
-
235
- if ($wppb_defaultOptions['yahoo'] == 'show'){
236
- $_POST['yim'] = apply_filters('wppb_edit_profile_posted_yahoo', $_POST['yim']);
237
- if ($wppb_defaultOptions['yahooRequired'] == 'yes'){
238
- if ((trim($_POST['yim']) != '') && isset($_POST['yim'])){
239
- update_user_meta( $current_user->id, 'yim', esc_attr( $_POST['yim'] ) );
240
- $changesSaved = 'yes';
241
- }
242
- }else{
243
- update_user_meta( $current_user->id, 'yim', esc_attr( $_POST['yim'] ) );
244
- $changesSaved = 'yes';
245
- }
246
- }
247
-
248
- if ($wppb_defaultOptions['jabber'] == 'show'){
249
- $_POST['jabber'] = apply_filters('wppb_edit_profile_posted_jabber', $_POST['jabber']);
250
- if ($wppb_defaultOptions['jabberRequired'] == 'yes'){
251
- if ((trim($_POST['jabber']) != '') && isset($_POST['jabber'])){
252
- update_user_meta( $current_user->id, 'jabber', esc_attr( $_POST['jabber'] ) );
253
- $changesSaved = 'yes';
254
- }
255
- }else{
256
- update_user_meta( $current_user->id, 'jabber', esc_attr( $_POST['jabber'] ) );
257
- $changesSaved = 'yes';
258
- }
259
- }
260
-
261
- if ($wppb_defaultOptions['bio'] == 'show'){
262
- $_POST['description'] = apply_filters('wppb_edit_profile_posted_bio', $_POST['description']);
263
- if ($wppb_defaultOptions['bioRequired'] == 'yes'){
264
- if ((trim($_POST['description']) != '') && isset($_POST['description'])){
265
- update_user_meta( $current_user->id, 'description', esc_attr( $_POST['description'] ) );
266
- $changesSaved = 'yes';
267
- }
268
- }else{
269
- update_user_meta( $current_user->id, 'description', esc_attr( $_POST['description'] ) );
270
- $changesSaved = 'yes';
271
- }
272
- }
273
-
274
- /* update the extra profile information */
275
- $wppb_premium = wppb_plugin_dir . '/premium/functions/';
276
- if (file_exists ( $wppb_premium.'extra.fields.php' )){
277
- $wppbFetchArray = get_option('wppb_custom_fields');
278
- foreach ( $wppbFetchArray as $key => $value){
279
- switch ($value['item_type']) {
280
- case "input":{
281
- $_POST[$value['item_id'].$value['id']] = apply_filters('wppb_edit_profile_input_custom_field_'.$value['id'], $_POST[$value['item_id'].$value['id']]);
282
- if (isset($value['item_required'])){
283
- if ($value['item_required'] == 'yes'){
284
- if (trim($_POST[$value['item_id'].$value['id']]) != '')
285
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
286
- else
287
- array_push($extraFieldsErrorHolder, $value['id']);
288
- }else
289
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
290
- }else
291
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
292
-
293
- break;
294
- }
295
- case "hiddenInput":{
296
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
297
-
298
- break;
299
- }
300
- case "checkbox":{
301
- $checkboxOption = '';
302
- $checkboxValue = explode(',', $value['item_options']);
303
- foreach($checkboxValue as $thisValue){
304
- $thisValue = str_replace(' ', '#@space@#', $thisValue); //we need to escape the space-codification we sent earlier in the post
305
- if (isset($_POST[$thisValue.$value['id']])){
306
- $localValue = str_replace('#@space@#', ' ', $_POST[$thisValue.$value['id']]);
307
- $checkboxOption = $checkboxOption.$localValue.',';
308
- }
309
- }
310
-
311
- if (isset($value['item_required'])){
312
- if ($value['item_required'] == 'yes'){
313
- if (trim($checkboxOption) != '')
314
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $checkboxOption ) );
315
- else
316
- array_push($extraFieldsErrorHolder, $value['id']);
317
- }else
318
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $checkboxOption ) );
319
- }else
320
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $checkboxOption ) );
321
-
322
- break;
323
- }
324
- case "radio":{
325
- if (isset($value['item_required'])){
326
- if ($value['item_required'] == 'yes'){
327
- if (trim($_POST[$value['item_id'].$value['id']]) != '')
328
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
329
- else
330
- array_push($extraFieldsErrorHolder, $value['id']);
331
- }else
332
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
333
- }else
334
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
335
- break;
336
- }
337
- case "select":{
338
- if (isset($value['item_required'])){
339
- if ($value['item_required'] == 'yes'){
340
- if (trim($_POST[$value['item_id'].$value['id']]) != '')
341
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
342
- else
343
- array_push($extraFieldsErrorHolder, $value['id']);
344
- }else
345
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
346
- }else
347
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
348
- break;
349
- }
350
- case "countrySelect":{
351
- if (isset($value['item_required'])){
352
- if ($value['item_required'] == 'yes'){
353
- if (trim($_POST[$value['item_id'].$value['id']]) != '')
354
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
355
- else
356
- array_push($extraFieldsErrorHolder, $value['id']);
357
- }else
358
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
359
- }else
360
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
361
-
362
- break;
363
- }
364
- case "timeZone":{
365
- if (isset($value['item_required'])){
366
- if ($value['item_required'] == 'yes'){
367
- if (trim($_POST[$value['item_id'].$value['id']]) != '')
368
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
369
- else
370
- array_push($extraFieldsErrorHolder, $value['id']);
371
- }else
372
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
373
- }else
374
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
375
-
376
- break;
377
- }
378
- case "datepicker":{
379
- if (isset($value['item_required'])){
380
- if ($value['item_required'] == 'yes'){
381
- if (trim($_POST[$value['item_id'].$value['id']]) != '')
382
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
383
- else
384
- array_push($extraFieldsErrorHolder, $value['id']);
385
- }else
386
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
387
- }else
388
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
389
-
390
- break;
391
- }
392
- case "textarea":{
393
- if (isset($value['item_required'])){
394
- if ($value['item_required'] == 'yes'){
395
- if (trim($_POST[$value['item_id'].$value['id']]) != '')
396
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
397
- else
398
- array_push($extraFieldsErrorHolder, $value['id']);
399
- }else
400
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
401
- }else
402
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
403
-
404
- break;
405
- }
406
- case "upload":{
407
- $uploadedfile = $value['item_type'].$value['id'];
408
-
409
- //first we need to verify if we don't try to upload a 0b or 0 length file
410
- if ( (basename( $_FILES[$uploadedfile]['name']) != '')){
411
-
412
- //second we need to verify if the uploaded file size is less then the set file size in php.ini
413
- if (($_FILES[$uploadedfile]['size'] < ServerMaxUploadSizeByte) && ($_FILES[$uploadedfile]['size'] !=0)){
414
- //we need to prepare the basename of the file, so that ' becomes ` as ' gives an error
415
- $fileName = basename( $_FILES[$uploadedfile]['name']);
416
- $finalFileName = '';
417
-
418
- for ($i=0; $i < strlen($fileName); $i++){
419
- if ($fileName[$i] == "'")
420
- $finalFileName .= '`';
421
- else $finalFileName .= $fileName[$i];
422
- }
423
-
424
- //create the target path for uploading
425
- $wpUploadPath = wp_upload_dir(); // Array of key => value pairs
426
- $target_path = $wpUploadPath['basedir']."/profile_builder/attachments/";
427
- //$target_path = "wp-content/uploads/profile_builder/attachments/";
428
- $target_path = $target_path . 'userID_'.$current_user->id.'_attachment_'. $finalFileName;
429
-
430
- if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)){
431
- //$upFile = get_bloginfo('home').'/'.$target_path;
432
- $upFile = $wpUploadPath['baseurl'].'/profile_builder/attachments/userID_'.$current_user->id.'_attachment_'. $finalFileName;
433
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], $upFile);
434
- $pictureUpload = 'yes';
435
- }else{
436
- //insert the name of the file in an array so that in case an error comes up, we know which files we just uploaded
437
- array_push($uploadName, basename( $_FILES[$uploadedfile]['name']));
438
- }
439
- }else{
440
- //insert the name of the file in an array so that in case an error comes up, we know which files we just uploaded
441
- array_push($uploadName, basename( $_FILES[$uploadedfile]['name']));
442
- }
443
- }
444
- break;
445
- }
446
- case "avatar":{
447
- $avatarUpload = 'no';
448
- $uploadedfile = $value['item_type'].$value['id'];
449
- $wpUploadPath = wp_upload_dir(); // Array of key => value pairs
450
- $target_path_original = $wpUploadPath['basedir']."/profile_builder/avatars/";
451
- $fileName = $_FILES[$uploadedfile]['name'];
452
- $finalFileName = '';
453
-
454
- for ($i=0; $i < strlen($fileName); $i++){
455
- if ($fileName[$i] == "'")
456
- $finalFileName .= '`';
457
- elseif ($fileName[$i] == ' ')
458
- $finalFileName .= '_';
459
- else $finalFileName .= $fileName[$i];
460
- }
461
-
462
- $fileName = $finalFileName;
463
-
464
- $target_path = $target_path_original . 'userID_'.$current_user->id.'_originalAvatar_'. $fileName;
465
- $target_path_avatar = $target_path_original . 'userID_'.$current_user->id.'_resziedAvatarSize_'.$value['item_options'].'_orignalName_'.$fileName;
466
-
467
- /* when trying to upload file, be sure it's one of the accepted image file-types */
468
- 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)) ){
469
- $avatarUpload = 'yes';
470
- $wp_filetype = wp_check_filetype(basename( $_FILES[$uploadedfile]['name']), null );
471
- $attachment = array(
472
- 'post_mime_type' => $wp_filetype['type'],
473
- 'post_title' => $fileName,
474
- 'post_content' => '',
475
- 'post_status' => 'inherit'
476
- );
477
-
478
-
479
- $attach_id = wp_insert_attachment( $attachment, $target_path);
480
- $attach_id_avatar = wp_insert_attachment( $attachment, $target_path_avatar);
481
-
482
- $upFile = image_downsize( $attach_id, 'thumbnail' );
483
- $upFile_avatar = image_downsize( $attach_id_avatar, 'thumbnail' );
484
- $upFile = $upFile[0];
485
- $upFile_avatar = $upFile_avatar[0];
486
-
487
- //calculate memory needed for file creation and allocate dynamically, in case of large files
488
- $memoryNeeded = round(($upFile[0] * $upFile[1] * $upFile['bits'] * $upFile['channels'] / 8 + Pow(2, 16)) * 1.8);
489
- $memoryHave = memory_get_usage();
490
- $memoryHave = memoryHave * Pow(1024,2);
491
- $memoryLimitMB = ini_get('memory_limit');
492
- $memoryLimit = substr ( $memoryLimitMB, 0, strlen($memoryLimitMB)-1 );
493
- $memoryLimit = $memoryLimit * Pow(1024,2);
494
-
495
- $newLimit = ceil( (($memoryHave + $memoryNeeded + $memoryLimit) / Pow(1024,2)) * 1.8 );
496
- ini_set( 'memory_limit', $newLimit . 'M' );
497
-
498
- //if file upload succeded
499
- if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)){
500
- // update the usermeta field with the original file url
501
- update_user_meta( $current_user->id, 'custom_field_'.$value['id'], $upFile);
502
-
503
- // also upload a resized image of it
504
- (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path_avatar));
505
-
506
-
507
- $extension = str_replace ( 'image/' , '' , $_FILES[$uploadedfile]['type']);
508
- if($extension=="jpg" || $extension=="jpeg" || $extension=="pjpeg" )
509
- $src = imagecreatefromjpeg($upFile);
510
- elseif($extension=="png" || $extension=="x-png")
511
- $src = imagecreatefrompng($upFile);
512
- else
513
- $src = imagecreatefromgif($upFile);
514
-
515
- list($width,$height)=getimagesize($upFile);
516
-
517
- $newwidth=$value['item_options'];
518
- $newheight=$value['item_options'];
519
- $tmp=imagecreatetruecolor($newwidth,$newheight);
520
-
521
- imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
522
- $filename = $target_path_avatar;
523
-
524
- imagejpeg($tmp,$filename,100);
525
-
526
- imagedestroy($src);
527
- imagedestroy($tmp);
528
-
529
- //restore the old value of the memory after imageprocessing is done
530
- ini_restore ( 'memory_limit' );
531
-
532
- // update/add a new usermeta field containing the url to the resized image
533
- update_user_meta( $current_user->id, 'custom_field_resized'.$value['id'], $upFile_avatar);
534
- }else $avatarUpload = 'no';
535
- }elseif ( (($_FILES[$uploadedfile]['size'] > ServerMaxUploadSizeByte) || ($_FILES[$uploadedfile]['size'] == 0)) && ($fileName != '') )
536
- $avatarUpload = 'no';
537
- elseif ($fileName == '')
538
- $avatarUpload = 'yes';
539
- break;
540
- }
541
- }
542
- }
543
- }
544
-
545
- }
546
-
547
- ?>
548
- <div class="wppb_holder" id="wppb_modify">
549
- <?php
550
- if ( !is_user_logged_in() ) :
551
- $editProfileFilterArray['notLoggedIn'] = '
552
- <p class="warning">'. __('You must be logged in to edit your profile.', 'profilebuilder') .'</p><!-- .warning -->';
553
- $editProfileFilterArray['notLoggedIn'] = apply_filters('wppb_edit_profile_user_not_logged_in', $editProfileFilterArray['notLoggedIn']);
554
- echo $editProfileFilterArray['notLoggedIn'];
555
-
556
- else :
557
- {
558
- /* messages for the the delete avatar/attachment */
559
- if (isset($_GET['fileType'])){
560
- if ($_GET['fileType'] == 'avatar'){
561
- $editProfileFilterArray['avatarChangesSaved'] = '
562
- <p class="changes-saved">'. __('The avatar was successfully deleted.', 'profilebuilder') .'</p><!-- .changes-saved -->';
563
- $editProfileFilterArray['avatarChangesSaved'] = apply_filters('wppb_edit_profile_avatar_changes_saved', $editProfileFilterArray['avatarChangesSaved']);
564
- echo $editProfileFilterArray['avatarChangesSaved'];
565
- unset($_GET['fileType']);
566
- }elseif ($_GET['fileType'] == 'attachment'){
567
- $editProfileFilterArray['attachmentChangesSaved'] = '
568
- <p class="changes-saved">'.
569
- __('The attachment', 'profilebuilder') .' "'. $_GET['fileName'] .'" '. __('was successfully deleted.', 'profilebuilder') .'
570
- </p><!-- .changes-saved -->';
571
- $editProfileFilterArray['attachmentChangesSaved'] = apply_filters('wppb_edit_profile_attachment_changes_saved', $editProfileFilterArray['attachmentChangesSaved']);
572
- echo $editProfileFilterArray['attachmentChangesSaved'];
573
- unset($_GET['fileType']);
574
- unset($_GET['fileName']);
575
- }
576
- }
577
-
578
- /* all the other messages/errors */
579
- $nrOfBadUploads = 0;
580
- $nrOfBadUploads = count($uploadName);
581
-
582
- if (($changesSaved == 'yes') && ($changesSavedNoMatchingPass == 'no') && ($changesSavedNoPass == 'no') && ($changesSavedNoEmail == 'no') && ($changesSavedNoEmailExist == 'no') && ($avatarUpload == 'yes') && ($nrOfBadUploads == 0)){
583
- $editProfileFilterArray['allChangesSaved'] = '
584
- <p class="changes-saved">'. __('The changes have been successfully saved.', 'profilebuilder') .'</p><!-- .changes-saved -->';
585
- $editProfileFilterArray['allChangesSaved'] = apply_filters('wppb_edit_profile_all_changes_saved', $editProfileFilterArray['allChangesSaved']);
586
- echo $editProfileFilterArray['allChangesSaved'];
587
- }
588
- elseif (($changesSaved == 'yes') && ($changesSavedNoEmailExist == 'yes') && ($previousError == 'no')){
589
- $editProfileFilterArray['allChangesSavedExceptExistingEmail'] = '
590
- <p class="semi-saved"> '.
591
- __('The email address you entered is already registered to a different user.', 'profilebuilder') .'<br/>'. __('The email address was', 'profilebuilder') .' <span class="error">'. __('NOT', 'profilebuilder') .'</span> '. __('updated along with the rest of the information.', 'profilebuilder') .'
592
- </p>';
593
- $editProfileFilterArray['allChangesSavedExceptExistingEmail'] = apply_filters('wppb_edit_profile_all_changes_saved_except_existing_email', $editProfileFilterArray['allChangesSavedExceptExistingEmail']);
594
- echo $editProfileFilterArray['allChangesSavedExceptExistingEmail'];
595
- $previousError = 'yes';
596
- }
597
-
598
- if (($changesSaved == 'yes') && ($changesSavedNoEmail == 'yes') && ($previousError == 'no')){
599
- $editProfileFilterArray['allChangesSavedExceptInvalidEmail'] = '
600
- <p class="semi-saved"> '.
601
- __('The email address you entered is invalid.', 'profilebuilder') .'<br/>'. __('The email address was', 'profilebuilder') .' <span class="error">'. __('NOT', 'profilebuilder') .'</span> '. __('updated along with the rest of the information.', 'profilebuilder') .'
602
- </p>';
603
- $editProfileFilterArray['allChangesSavedExceptInvalidEmail'] = apply_filters('wppb_edit_profile_all_changes_saved_except_invalid_email', $editProfileFilterArray['allChangesSavedExceptInvalidEmail']);
604
- echo $editProfileFilterArray['allChangesSavedExceptInvalidEmail'];
605
- $previousError = 'yes';
606
- }
607
-
608
- if (($changesSaved == 'yes') && ($changesSavedNoMatchingPass == 'yes') && ($previousError == 'no')){
609
- $editProfileFilterArray['allChangesSavedMismatchedPass'] = '
610
- <p class="semi-saved">';
611
- __('The passwords you entered do not match.', 'profilebuilder') .'<br/>'. __('The password was', 'profilebuilder') .' <span class="error">'. __('NOT', 'profilebuilder') .'</span> '. __('updated along with the rest of the information.', 'profilebuilder') .'
612
- </p>';
613
- $editProfileFilterArray['allChangesSavedMismatchedPass'] = apply_filters('wppb_edit_profile_all_changes_saved_except_mismatch_password', $editProfileFilterArray['allChangesSavedMismatchedPass']);
614
- echo $editProfileFilterArray['allChangesSavedMismatchedPass'];
615
- $previousError = 'yes';
616
- }
617
- if (($changesSaved == 'yes') && ($changesSavedNoPass == 'yes') && ($previousError == 'no')){
618
- $editProfileFilterArray['allChangesSavedUncompletedPass'] = '
619
- <p class="semi-saved">'.
620
- __('You didn\'t complete both password fields.', 'profilebuilder') .'<br/>'. __('The password was', 'profilebuilder') .' <span class="error">'. __('NOT', 'profilebuilder') .'</span> '. __('updated along with the rest of the information.', 'profilebuilder') .'
621
- </p>';
622
- $editProfileFilterArray['allChangesSavedUncompletedPass'] = apply_filters('wppb_edit_profile_all_changes_saved_except_uncompleted_password', $editProfileFilterArray['allChangesSavedUncompletedPass']);
623
- echo $editProfileFilterArray['allChangesSavedUncompletedPass'];
624
- $previousError = 'yes';
625
- }
626
- if ($allRequiredCompleted == 'no'){
627
- $editProfileFilterArray['errorSavingChanges'] = '<p class="error">'.$errorMessage.'<br/>'. __('Your profile was NOT updated!', 'profilebuilder').'</p><!-- .error -->';
628
- $editProfileFilterArray['errorSavingChanges'] = apply_filters('wppb_edit_profile_error_saving_changes', $editProfileFilterArray['errorSavingChanges']);
629
- echo $editProfileFilterArray['errorSavingChanges'];
630
- }
631
- $wppb_premium = wppb_plugin_dir . '/premium/functions/';
632
- if (file_exists ( $wppb_premium.'extra.fields.php' )){
633
- if (($changesSaved == 'yes') && ($nrOfBadUploads > 0) && ($previousError == 'no')){
634
- $lastOne = 0;
635
- $editProfileFilterArray['errorUploadingAttachments'] = '
636
- <p class="semi-saved">'. __('There was an error while trying to upload the following attachments:', 'profilebuilder') .'<br/>
637
- <span class="error">';
638
- foreach ($uploadName as $key => $name){
639
- $lastOne++;
640
- $editProfileFilterArray['errorUploadingAttachments'] .= $name;
641
- if ($nrOfBadUploads-$lastOne > 0)
642
- $editProfileFilterArray['errorUploadingAttachments'] .= ';<span style="padding-left:10px"></span>';
643
- }
644
- $editProfileFilterArray['errorUploadingAttachments'] .= '
645
- </span><br/>'.
646
- __('Possible cause: the size was bigger than', 'profilebuilder') .' '.ServerMaxUploadSizeMega.'b.<br/>'. __('The listed attachements were', 'profilebuilder') .' <span class="error">'. __('NOT', 'profilebuilder') .'</span> '. __('updated along with the rest of the information.', 'profilebuilder') .'
647
- </p>';
648
- $editProfileFilterArray['errorUploadingAttachments'] = apply_filters('wppb_edit_profile_error_uploading_attachments', $editProfileFilterArray['errorUploadingAttachments']);
649
- echo $editProfileFilterArray['errorUploadingAttachments'];
650
- $previousError = 'yes';
651
- }if (($changesSaved == 'yes') && ($avatarUpload == 'no') && ($previousError == 'no')){
652
- $editProfileFilterArray['errorUploadingAvatar'] = '
653
- <p class="semi-saved">'.
654
- __('There was an error while trying to upload your avatar picture.', 'profilebuilder') .'<br/>'. __('Possible cause: size/incorrect file-type.', 'profilebuilder') .'<br/>'. __('The avatar was', 'profilebuilder') .' <span class="error">'. __('NOT', 'profilebuilder') .'</span> '. __('updated along with the rest of the information.', 'profilebuilder') .'
655
- </p>';
656
- $editProfileFilterArray['errorUploadingAvatar'] = apply_filters('wppb_edit_profile_error_uploading_avatar', $editProfileFilterArray['errorUploadingAvatar']);
657
- echo $editProfileFilterArray['errorUploadingAvatar'];
658
- $previousError = 'yes';
659
- }
660
- }
661
- }
662
-
663
- /* use this action hook to add extra content before the edit profile form. */
664
- do_action( 'wppb_before_edit_profile_fields' );
665
- ?>
666
-
667
- <form enctype="multipart/form-data" method="post" id="edituser" class="user-forms" action="<?php the_permalink(); ?>">
668
- <?php
669
- 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 -->';
670
-
671
- $editProfileFilterArray['contentName1'] = '<p class="nameHeader"><strong>'. __('Name', 'profilebuilder') .'</strong></p>';
672
- $editProfileFilterArray['contentName1'] = apply_filters('wppb_edit_profile_content_name1', $editProfileFilterArray['contentName1']);
673
- echo $editProfileFilterArray['contentName1'];
674
-
675
- if ($wppb_defaultOptions['username'] == 'show'){
676
- $editProfileFilterArray['contentName2'] = '
677
- <p class="username">
678
- <label for="user_login">'. __('Username', 'profilebuilder') .'</label>
679
- <input class="text-input" name="user_login" type="text" id="user_login" value="'. get_the_author_meta( 'user_login', $current_user->id ) .'" disabled="disabled"/> <span class="wppb-description-delimiter"> '. __('Usernames cannot be changed.', 'profilebuilder') .'</span>
680
- </p><!-- .first_name -->';
681
- $editProfileFilterArray['contentName2'] = apply_filters('wppb_edit_profile_content_name2', $editProfileFilterArray['contentName2']);
682
- echo $editProfileFilterArray['contentName2'];
683
- }
684
-
685
- if ($wppb_defaultOptions['firstname'] == 'show'){
686
- $errorVar = '';
687
- $errorMark = '';
688
- if ($wppb_defaultOptions['firstnameRequired'] == 'yes'){
689
- $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
690
- if (isset($_POST['first_name'])){
691
- if (trim($_POST['first_name']) == ''){
692
- $errorMark = '<img src="'.wppb_plugin_url . '/assets/images/pencil_delete.png" title="This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator)."/>';
693
- $errorVar = ' errorHolder';
694
- }
695
- }
696
- }
697
- $editProfileFilterArray['contentName3'] = '
698
- <p class="first_name'.$errorVar.'">
699
- <label for="first_name">'. __('First Name', 'profilebuilder') .$errorMark.'</label>
700
- <input class="text-input" name="first_name" type="text" id="first_name" value="'. get_the_author_meta( 'first_name', $current_user->id ) .'" />
701
- </p><!-- .first_name -->';
702
- $editProfileFilterArray['contentName3'] = apply_filters('wppb_edit_profile_content_name3', $editProfileFilterArray['contentName3']);
703
- echo $editProfileFilterArray['contentName3'];
704
- }
705
-
706
- if ($wppb_defaultOptions['lastname'] == 'show'){
707
- $errorVar = '';
708
- $errorMark = '';
709
- if ($wppb_defaultOptions['lastnameRequired'] == 'yes'){
710
- $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
711
- if (isset($_POST['last_name'])){
712
- if (trim($_POST['last_name']) == ''){
713
- $errorMark = '<img src="'.wppb_plugin_url . '/assets/images/pencil_delete.png" title="This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator)."/>';
714
- $errorVar = ' errorHolder';
715
- }
716
- }
717
- }
718
- $editProfileFilterArray['contentName4'] = '
719
- <p class="last_name'.$errorVar.'">
720
- <label for="last_name">'. __('Last Name', 'profilebuilder') .$errorMark.'</label>
721
- <input class="text-input" name="last_name" type="text" id="last_name" value="'. get_the_author_meta( 'last_name', $current_user->id ) .'" />
722
- </p><!-- .last_name -->';
723
- $editProfileFilterArray['contentName4'] = apply_filters('wppb_edit_profile_content_name4', $editProfileFilterArray['contentName4']);
724
- echo $editProfileFilterArray['contentName4'];
725
- }
726
-
727
- if ($wppb_defaultOptions['nickname'] == 'show'){
728
- $errorVar = '';
729
- $errorMark = '';
730
- if ($wppb_defaultOptions['nicknameRequired'] == 'yes'){
731
- $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
732
- if (isset($_POST['nickname'])){
733
- if (trim($_POST['nickname']) == ''){
734
- $errorMark = '<img src="'.wppb_plugin_url . '/assets/images/pencil_delete.png" title="This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator)."/>';
735
- $errorVar = ' errorHolder';
736
- }
737
- }
738
- }
739
- $editProfileFilterArray['contentName5'] = '
740
- <p class="nickname'.$errorVar.'">
741
- <label for="nickname">'. __('Nickname', 'profilebuilder') .$errorMark.'</label>
742
- <input class="text-input" name="nickname" type="text" id="nickname" value="'. get_the_author_meta( 'nickname', $current_user->id ) .'" />
743
- <span class="wppb-description-delimiter">'. __('(required)', 'profilebuilder') .'</span>
744
- </p><!-- .nickname -->';
745
- $editProfileFilterArray['contentName5'] = apply_filters('wppb_edit_profile_content_name5', $editProfileFilterArray['contentName5']);
746
- echo $editProfileFilterArray['contentName5'];
747
- }
748
-
749
- if ($wppb_defaultOptions['dispname'] == 'show'){
750
- $errorVar = '';
751
- $errorMark = '';
752
- if ($wppb_defaultOptions['dispnameRequired'] == 'yes'){
753
- $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
754
- if (isset($_POST['display_name'])){
755
- if (trim($_POST['display_name']) == ''){
756
- $errorMark = '<img src="'.wppb_plugin_url . '/assets/images/pencil_delete.png" title="This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator)."/>';
757
- $errorVar = ' errorHolder';
758
- }
759
- }
760
- }
761
- echo '
762
- <p class="display_name'.$errorVar.'">
763
- <label for="display_name">'. __('Display name publicly as', 'profilebuilder') .$errorMark.'</label>
764
- <select name="display_name" id="display_name">';
765
- $public_display = array();
766
- $public_display['display_username'] = get_the_author_meta('user_login', $current_user->id);
767
- $thisFirstName = get_the_author_meta('first_name', $current_user->id);
768
- if ( !empty($thisFirstName))
769
- $public_display['display_firstname'] = get_the_author_meta('first_name', $current_user->id);
770
- $thisLastName = get_the_author_meta('last_name', $current_user->id);
771
- if ( !empty($thisLastName))
772
- $public_display['display_lastname'] = get_the_author_meta('last_name', $current_user->id);
773
- $public_display['display_nickname'] = get_the_author_meta('nickname', $current_user->id);
774
- if ( !empty($thisFirstName) && !empty($thisLastName) ) {
775
- $public_display['display_firstlast'] = $thisFirstName . ' ' . $thisLastName;
776
- $public_display['display_lastfirst'] = $thisLastName . ' ' . $thisFirstName;
777
- }
778
- $thisDisplayName = get_the_author_meta('display_name', $current_user->id);
779
- if ( !in_array( $thisDisplayName, $public_display ) ) // Only add this if it isn't duplicated elsewhere
780
- $public_display = array( 'display_displayname' => $thisDisplayName ) + $public_display;
781
- $public_display = array_map( 'trim', $public_display );
782
- foreach ( $public_display as $id => $item ) {
783
- echo '<option id="'.$id.'" value="'.$item.'"'; selected( $thisDisplayName, $item ); echo'>'.$item.'</option>';
784
- }
785
- echo '
786
- </select>
787
- </p><!-- .display_name -->';
788
- }
789
-
790
- $editProfileFilterArray['contentInfo1'] = '<p class="contactInfoHeader"><strong>'. __('Contact Info', 'profilebuilder') .'</strong></p>';
791
- $editProfileFilterArray['contentInfo1'] = apply_filters('wppb_edit_profile_content_info1', $editProfileFilterArray['contentInfo1']);
792
- echo $editProfileFilterArray['contentInfo1'];
793
-
794
- if ($wppb_defaultOptions['email'] == 'show'){
795
- $errorVar = '';
796
- $errorMark = '';
797
- if ($wppb_defaultOptions['emailRequired'] == 'yes'){
798
- $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
799
- if (isset($_POST['email'])){
800
- if (trim($_POST['email']) == ''){
801
- $errorMark = '<img src="'.wppb_plugin_url . '/assets/images/pencil_delete.png" title="This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator)."/>';
802
- $errorVar = ' errorHolder';
803
- }
804
- }
805
- }
806
- $editProfileFilterArray['contentInfo2'] = '
807
- <p class="form-email'.$errorVar.'">
808
- <label for="email">'. __('E-mail', 'profilebuilder') .$errorMark.'</label>
809
- <input class="text-input" name="email" type="text" id="email" value="'. get_the_author_meta( 'user_email', $current_user->id ) .'" />
810
- <span class="wppb-description-delimiter">'. __('(required)', 'profilebuilder') .'</span>
811
- </p><!-- .form-email -->';
812
- $editProfileFilterArray['contentInfo2'] = apply_filters('wppb_edit_profile_content_info2', $editProfileFilterArray['contentInfo2']);
813
- echo $editProfileFilterArray['contentInfo2'];
814
- }
815
-
816
- if ($wppb_defaultOptions['website'] == 'show'){
817
- $errorVar = '';
818
- $errorMark = '';
819
- if ($wppb_defaultOptions['websiteRequired'] == 'yes'){
820
- $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
821
- if ((trim($_POST['website']) == '') && isset($_POST['website'])){
822
- $errorMark = '<img src="'.wppb_plugin_url . '/assets/images/pencil_delete.png" title="This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator)."/>';
823
- $errorVar = ' errorHolder';
824
- }
825
- }
826
- $editProfileFilterArray['contentInfo3'] = '
827
- <p class="form-website'.$errorVar.'">
828
- <label for="website">'. __('Website', 'profilebuilder') .$errorMark.'</label>
829
- <input class="text-input" name="website" type="text" id="website" value="'. get_the_author_meta( 'user_url', $current_user->id ) .'" />
830
- </p><!-- .form-website -->';
831
- $editProfileFilterArray['contentInfo3'] = apply_filters('wppb_edit_profile_content_info3', $editProfileFilterArray['contentInfo3']);
832
- echo $editProfileFilterArray['contentInfo3'];
833
- }
834
-
835
- if ($wppb_defaultOptions['aim'] == 'show'){
836
- $errorVar = '';
837
- $errorMark = '';
838
- if ($wppb_defaultOptions['aimRequired'] == 'yes'){
839
- $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
840
- if ((trim($_POST['aim']) == '') && isset($_POST['aim'])){
841
- $errorMark = '<img src="'.wppb_plugin_url . '/assets/images/pencil_delete.png" title="This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator)."/>';
842
- $errorVar = ' errorHolder';
843
- }
844
- }
845
- $editProfileFilterArray['contentInfo4'] = '
846
- <p class="form-aim'.$errorVar.'">
847
- <label for="aim">'. __('AIM', 'profilebuilder') .'</label>
848
- <input class="text-input" name="aim" type="text" id="aim" value="'. get_the_author_meta( 'aim', $current_user->id ) .'" />
849
- </p><!-- .form-aim -->';
850
- $editProfileFilterArray['contentInfo4'] = apply_filters('wppb_edit_profile_content_info4', $editProfileFilterArray['contentInfo4']);
851
- echo $editProfileFilterArray['contentInfo4'];
852
- }
853
-
854
- if ($wppb_defaultOptions['yahoo'] == 'show'){
855
- $errorVar = '';
856
- $errorMark = '';
857
- if ($wppb_defaultOptions['yahooRequired'] == 'yes'){
858
- $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
859
- if ((trim($_POST['yim']) == '') && isset($_POST['yim'])){
860
- $errorMark = '<img src="'.wppb_plugin_url . '/assets/images/pencil_delete.png" title="This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator)."/>';
861
- $errorVar = ' errorHolder';
862
- }
863
- }
864
- $editProfileFilterArray['contentInfo5'] = '
865
- <p class="form-yim'.$errorVar.'">
866
- <label for="yim">'. __('Yahoo IM', 'profilebuilder') .$errorMark.'</label>
867
- <input class="text-input" name="yim" type="text" id="yim" value="'. get_the_author_meta( 'yim', $current_user->id ) .'" />
868
- </p><!-- .form-yim -->';
869
- $editProfileFilterArray['contentInfo5'] = apply_filters('wppb_edit_profile_content_info5', $editProfileFilterArray['contentInfo5']);
870
- echo $editProfileFilterArray['contentInfo5'];
871
- }
872
-
873
- if ($wppb_defaultOptions['jabber'] == 'show'){
874
- $errorVar = '';
875
- $errorMark = '';
876
- if ($wppb_defaultOptions['jabberRequired'] == 'yes'){
877
- $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
878
- if ((trim($_POST['jabber']) == '') && isset($_POST['jabber'])){
879
- $errorMark = '<img src="'.wppb_plugin_url . '/assets/images/pencil_delete.png" title="This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator)."/>';
880
- $errorVar = ' errorHolder';
881
- }
882
- }
883
- $editProfileFilterArray['contentInfo6'] = '
884
- <p class="form-jabber'.$errorVar.'">
885
- <label for="jabber">'. __('Jabber / Google Talk', 'profilebuilder') .$errorMark.'</label>
886
- <input class="text-input" name="jabber" type="text" id="jabber" value="'. get_the_author_meta( 'jabber', $current_user->id ) .'" />
887
- </p><!-- .form-jabber -->';
888
- $editProfileFilterArray['contentInfo6'] = apply_filters('wppb_edit_profile_content_info6', $editProfileFilterArray['contentInfo6']);
889
- echo $editProfileFilterArray['contentInfo6'];
890
- }
891
-
892
- $editProfileFilterArray['aboutYourself1'] = '<p class="aboutYourselfHeader"><strong>'. __('About Yourself', 'profilebuilder') .'</strong></p>';
893
- $editProfileFilterArray['aboutYourself1'] = apply_filters('wppb_edit_profile_content_about_yourself1', $editProfileFilterArray['aboutYourself1']);
894
- echo $editProfileFilterArray['aboutYourself1'];
895
-
896
- if ($wppb_defaultOptions['bio'] == 'show'){
897
- $errorVar = '';
898
- $errorMark = '';
899
- if ($wppb_defaultOptions['bioRequired'] == 'yes'){
900
- $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
901
- if ((trim($_POST['description']) == '') && isset($_POST['description'])){
902
- $errorMark = '<img src="'.wppb_plugin_url . '/assets/images/pencil_delete.png" title="This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator)."/>';
903
- $errorVar = ' errorHolder';
904
- }
905
- }
906
- $editProfileFilterArray['aboutYourself2'] = '
907
- <p class="form-description'.$errorVar.'">
908
- <label for="description">'. __('Biographical Info', 'profilebuilder') .$errorMark.'</label>
909
- <textarea class="text-input" name="description" id="description" rows="5" cols="30">'. get_the_author_meta( 'description', $current_user->id ) .'</textarea>
910
- </p><!-- .form-description -->';
911
- $editProfileFilterArray['aboutYourself2'] = apply_filters('wppb_edit_profile_content_about_yourself2', $editProfileFilterArray['aboutYourself2']);
912
- echo $editProfileFilterArray['aboutYourself2'];
913
- }
914
-
915
- if ($wppb_defaultOptions['password'] == 'show'){
916
-
917
- $editProfileFilterArray['aboutYourself3'] = '
918
- <p class="form-password">
919
- <label for="pass1">'. __('New Password', 'profilebuilder') .'</label>
920
- <input class="text-input" name="pass1" type="password" id="pass1" />
921
- </p><!-- .form-password -->
922
-
923
- <p class="form-password'.$errorVar.'">
924
- <label for="pass2">'. __('Repeat Password', 'profilebuilder') .$errorMark.'</label>
925
- <input class="text-input" name="pass2" type="password" id="pass2" />
926
- </p><!-- .form-password -->';
927
- $editProfileFilterArray['aboutYourself3'] = apply_filters('wppb_edit_profile_content_about_yourself3', $editProfileFilterArray['aboutYourself3']);
928
- echo $editProfileFilterArray['aboutYourself3'];
929
- }
930
-
931
-
932
- $wppb_premium = wppb_plugin_dir . '/premium/functions/';
933
- if (file_exists ( $wppb_premium.'extra.fields.php' )){
934
- require_once($wppb_premium.'extra.fields.php');
935
- edit_profile_extra_fields($current_user->id, $extraFieldsErrorHolder);
936
- }
937
- ?>
938
-
939
-
940
- <p class="form-submit">
941
- <input name="updateuser" type="submit" id="updateuser" class="submit button" value="<?php _e('Update', 'profilebuilder'); ?>" />
942
- <?php// wp_nonce_field( 'update-user' ) ?>
943
- <input name="action" type="hidden" id="action" value="update-user" />
944
- </p><!-- .form-submit -->
945
- <?php wp_nonce_field('verify_edit_user','edit_nonce_field'); ?>
946
- </form><!-- #edituser -->
947
-
948
- <?php endif; ?>
949
-
950
- <?php /* use this action hook to add extra content after the edit profile form. */ ?>
951
- <?php do_action( 'wppb_after_edit_profile_fields' ); ?>
952
-
953
- </div>
954
-
955
- <?php
956
- $output = ob_get_contents();
957
- ob_end_clean();
958
-
959
- $editProfileFilterArray = apply_filters('wppb_edit_profile', $editProfileFilterArray);
960
-
961
- return $output;
962
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
963
  ?>
1
+ <?php
2
+ /*
3
+ wp_update_user only attempts to clear and reset cookies if it's updating the password.
4
+ The php function setcookie(), used in both the cookie-clearing and cookie-resetting functions,
5
+ adds to the page headers and therefore must be called within the first php tag on the page, and
6
+ before the WordPress get_header() function. Since wp_update_user needs this, it must be at the
7
+ beginning of the page as well.
8
+ */
9
+ $changesSaved = 'no';
10
+ $changesSavedNoMatchingPass = 'no';
11
+ $changesSavedNoPass = 'no';
12
+
13
+ function wppb_save_the_password(){
14
+ global $changesSaved;
15
+ global $changesSavedNoMatchingPass;
16
+ global $changesSavedNoPass;
17
+
18
+ /* Load registration file. */
19
+ require_once(ABSPATH . WPINC . '/registration.php');
20
+ /* Get user info. */
21
+ global $current_user;
22
+
23
+ if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'update-user' && wp_verify_nonce($_POST['edit_nonce_field'],'verify_edit_user') ) {
24
+ /* Update user password. */
25
+ if ( !empty($_POST['pass1'] ) && !empty( $_POST['pass2'] ) ){
26
+ if ( $_POST['pass1'] == $_POST['pass2'] ){
27
+ wp_update_user( array( 'ID' => $current_user->id, 'user_pass' => esc_attr( $_POST['pass1'] ) ) );
28
+ $changesSaved = 'yes';
29
+ } else {
30
+ $changesSavedNoMatchingPass = 'yes';
31
+ }
32
+ }elseif (( empty($_POST['pass1'] ) && !empty( $_POST['pass2'] )) || ( !empty($_POST['pass1'] ) && empty( $_POST['pass2'] )) ) {
33
+ $changesSavedNoPass = 'yes';
34
+ }
35
+ }
36
+ }
37
+ add_action('init', 'wppb_save_the_password');
38
+
39
+ function wppb_front_end_profile_info() {
40
+
41
+ global $changesSaved;
42
+ global $changesSavedNoMatchingPass;
43
+ global $changesSavedNoPass;
44
+ $editProfileFilterArray = array();
45
+ $editProfileFilterArray2 = array();
46
+ $extraFieldsErrorHolder = array(); //we will use this array to store the ID's of the extra-fields left uncompleted
47
+
48
+ global $wppb_shortcode_on_front;
49
+
50
+ $wppb_shortcode_on_front = true;
51
+ ob_start();
52
+ get_currentuserinfo();
53
+ $wppb_defaultOptions = get_option('wppb_default_settings');
54
+ $changesSavedNoEmail = 'no';
55
+ $changesSavedNoEmailExist = 'no';
56
+ $previousError = 'no';
57
+ $pictureUpload = 'no';
58
+ $avatarUpload = 'yes';
59
+ $allRequiredCompleted = 'yes';
60
+ $uploadName = array();
61
+ $uploadExt = array();
62
+ $uploadSize = array();
63
+ $editFilterArray = array();
64
+
65
+
66
+ /* Load registration file. */
67
+ require_once(ABSPATH . WPINC . '/registration.php');
68
+ /* Get user info. */
69
+ global $current_user;
70
+
71
+ /* delete the attachment if set */
72
+ if (isset($_GET['userID']) && isset($_GET['field'])){
73
+ update_user_meta( $_GET['userID'], $_GET['field'], '');
74
+ }
75
+ /* delete the avatar */
76
+ if (isset($_GET['userID']) && isset($_GET['fieldOriginal']) && isset($_GET['fieldResized'])){
77
+ update_user_meta( $_GET['userID'], $_GET['fieldOriginal'], '');
78
+ update_user_meta( $_GET['userID'], $_GET['fieldResized'], '');
79
+ }
80
+
81
+ //fallback if the file was largen then post_max_size, case in which no errors can be saved in $_FILES[fileName]['error']
82
+ if (empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
83
+ $editProfileFilterArray['noPost'] = '
84
+ <p class="error">'.
85
+ __('The information size you were trying to submit was larger than', 'profilebuilder') .' '. WPPB_SERVER_MAX_UPLOAD_SIZE_MEGA .'b!<br/>'.
86
+ __('This is usually caused by a large file(s) trying to be uploaded.', 'profilebuilder') .'<br/>'.
87
+ __('Since it was also larger than', 'profilebuilder') .' '. WPPB_SERVER_MAX_POST_SIZE_MEGA .'b '. __('no additional information is available.', 'profilebuilder') .'<br/>
88
+ </p>';
89
+ $editProfileFilterArray['noPost'] = apply_filters('wppb_edit_profile_no_post_error', $editProfileFilterArray['noPost']);
90
+ echo $editProfileFilterArray['noPost'];
91
+ }
92
+ // a way to catch the user before updating his/her profile without completing a required field
93
+ if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'update-user' && wp_verify_nonce($_POST['edit_nonce_field'],'verify_edit_user') ) {
94
+ //variable to control whether the user submitted data or not
95
+
96
+ $allRequiredCompleted = apply_filters('wppb_edit_profile_all_required_completed', $allRequiredCompleted);
97
+ }
98
+
99
+ /* If profile was saved, update profile. */
100
+ if ( ('POST' == $_SERVER['REQUEST_METHOD']) && (!empty( $_POST['action'] )) && ($_POST['action'] == 'update-user') && (wp_verify_nonce($_POST['edit_nonce_field'],'verify_edit_user')) && ($allRequiredCompleted == 'yes') ) {
101
+
102
+ $_POST['email'] = apply_filters('wppb_edit_profile_posted_email', $_POST['email']);
103
+ if ($wppb_defaultOptions['emailRequired'] == 'yes'){
104
+ if ((trim($_POST['email']) != '') && isset($_POST['email'])){
105
+ if (email_exists( $_POST['email'] ) != FALSE)
106
+ $thisEmail = email_exists( $_POST['email'] );
107
+ else $thisEmail = $current_user->id;
108
+
109
+ if ( !empty( $_POST['email'] ) && is_email( $_POST['email'] )){ // if the user entered a valid email address
110
+ if (($thisEmail == $current_user->id)){ // if the entered email address is not already registered to some other user
111
+ wp_update_user( array( 'ID' => $current_user->id, 'user_email' => esc_attr( $_POST['email'] )));
112
+ $changesSaved = 'yes';
113
+ }else{
114
+ $changesSavedNoEmailExist = 'yes';
115
+ }
116
+ }else{
117
+ $changesSavedNoEmail = 'yes';
118
+ }
119
+ }
120
+ }else{
121
+ if (email_exists( $_POST['email'] ) != FALSE)
122
+ $thisEmail = email_exists( $_POST['email'] );
123
+ else $thisEmail = $current_user->id;
124
+
125
+ if ( !empty( $_POST['email'] ) && is_email( $_POST['email'] )){ // if the user entered a valid email address
126
+ if (($thisEmail == $current_user->id)){ // if the entered email address is not already registered to some other user
127
+ wp_update_user( array( 'ID' => $current_user->id, 'user_email' => esc_attr( $_POST['email'] )));
128
+ $changesSaved = 'yes';
129
+ }else{
130
+ $changesSavedNoEmailExist = 'yes';
131
+ }
132
+ }else{
133
+ $changesSavedNoEmail = 'yes';
134
+ }
135
+ }
136
+
137
+
138
+ /* Update user information. */
139
+ if ($wppb_defaultOptions['firstname'] == 'show'){
140
+ $_POST['first_name'] = apply_filters('wppb_edit_profile_posted_first_name', $_POST['first_name']);
141
+ if ($wppb_defaultOptions['firstnameRequired'] == 'yes'){
142
+ if ((trim($_POST['first_name']) != '') && isset($_POST['first_name'])){
143
+ wp_update_user( array( 'ID' => $current_user->id, 'first_name' => esc_attr( $_POST['first_name'] )));
144
+ $changesSaved = 'yes';
145
+ }
146
+ }else{
147
+ wp_update_user( array( 'ID' => $current_user->id, 'first_name' => esc_attr( $_POST['first_name'] )));
148
+ $changesSaved = 'yes';
149
+ }
150
+ }
151
+
152
+ if ($wppb_defaultOptions['lastname'] == 'show'){
153
+ $_POST['last_name'] = apply_filters('wppb_edit_profile_posted_last_name', $_POST['last_name']);
154
+ if ($wppb_defaultOptions['lastnameRequired'] == 'yes'){
155
+ if ((trim($_POST['last_name']) != '') && isset($_POST['last_name'])){
156
+ wp_update_user( array( 'ID' => $current_user->id, 'last_name' => esc_attr( $_POST['last_name'] )));
157
+ $changesSaved = 'yes';
158
+ }
159
+ }else{
160
+ wp_update_user( array( 'ID' => $current_user->id, 'last_name' => esc_attr( $_POST['last_name'] )));
161
+ $changesSaved = 'yes';
162
+ }
163
+ }
164
+
165
+ if ($wppb_defaultOptions['nickname'] == 'show'){
166
+ $_POST['nickname'] = apply_filters('wppb_edit_profile_posted_nickname', $_POST['nickname']);
167
+ if ($wppb_defaultOptions['nicknameRequired'] == 'yes'){
168
+ if ((trim($_POST['nickname']) != '') && isset($_POST['nickname'])){
169
+ wp_update_user( array( 'ID' => $current_user->id, 'nickname' => esc_attr( $_POST['nickname'] )));
170
+ $changesSaved = 'yes';
171
+ }
172
+ }else{
173
+ wp_update_user( array( 'ID' => $current_user->id, 'nickname' => esc_attr( $_POST['nickname'] )));
174
+ $changesSaved = 'yes';
175
+ }
176
+
177
+ }
178
+
179
+ if ($wppb_defaultOptions['dispname'] == 'show'){
180
+ $_POST['display_name'] = apply_filters('wppb_edit_profile_posted_display_name', $_POST['display_name']);
181
+ if ($wppb_defaultOptions['dispnameRequired'] == 'yes'){
182
+ if ((trim($_POST['display_name']) != '') && isset($_POST['display_name'])){
183
+ wp_update_user( array( 'ID' => $current_user->id, 'display_name' => esc_attr( $_POST['display_name'] )));
184
+ $changesSaved = 'yes';
185
+ }
186
+ }else{
187
+ wp_update_user( array( 'ID' => $current_user->id, 'display_name' => esc_attr( $_POST['display_name'] )));
188
+ $changesSaved = 'yes';
189
+ }
190
+ }
191
+
192
+ if ($wppb_defaultOptions['website'] == 'show'){
193
+ $_POST['website'] = apply_filters('wppb_edit_profile_posted_website', $_POST['website']);
194
+ if ($wppb_defaultOptions['websiteRequired'] == 'yes'){
195
+ if ((trim($_POST['website']) != '') && isset($_POST['website'])){
196
+ $wppbPos = strpos($_POST['website'], 'http://');
197
+ if($wppbPos !== FALSE){
198
+ wp_update_user( array( 'ID' => $current_user->id, 'user_url' => esc_attr( $_POST['website'] )));
199
+ $changesSaved = 'yes';
200
+ }else{
201
+ wp_update_user( array( 'ID' => $current_user->id, 'user_url' => 'http://'.esc_attr( $_POST['website'] )));
202
+ $changesSaved = 'yes';
203
+ }
204
+ }
205
+ }else{
206
+ $wppbPos = strpos($_POST['website'], 'http://');
207
+ $website = esc_attr( $_POST['website'] );
208
+ if($wppbPos !== FALSE){
209
+ if ($website == 'http://')
210
+ $website = '';
211
+ wp_update_user( array( 'ID' => $current_user->id, 'user_url' => $website));
212
+ $changesSaved = 'yes';
213
+ }else{
214
+ if ($website != '')
215
+ $website = 'http://'.$website;
216
+ wp_update_user( array( 'ID' => $current_user->id, 'user_url' => $website));
217
+ $changesSaved = 'yes';
218
+ }
219
+ }
220
+ }
221
+
222
+ if ($wppb_defaultOptions['aim'] == 'show'){
223
+ $_POST['aim'] = apply_filters('wppb_edit_profile_posted_aim', $_POST['aim']);
224
+ if ($wppb_defaultOptions['aimRequired'] == 'yes'){
225
+ if ((trim($_POST['aim']) != '') && isset($_POST['aim'])){
226
+ update_user_meta( $current_user->id, 'aim', esc_attr( $_POST['aim'] ) );
227
+ $changesSaved = 'yes';
228
+ }
229
+ }else{
230
+ update_user_meta( $current_user->id, 'aim', esc_attr( $_POST['aim'] ) );
231
+ $changesSaved = 'yes';
232
+ }
233
+ }
234
+
235
+ if ($wppb_defaultOptions['yahoo'] == 'show'){
236
+ $_POST['yim'] = apply_filters('wppb_edit_profile_posted_yahoo', $_POST['yim']);
237
+ if ($wppb_defaultOptions['yahooRequired'] == 'yes'){
238
+ if ((trim($_POST['yim']) != '') && isset($_POST['yim'])){
239
+ update_user_meta( $current_user->id, 'yim', esc_attr( $_POST['yim'] ) );
240
+ $changesSaved = 'yes';
241
+ }
242
+ }else{
243
+ update_user_meta( $current_user->id, 'yim', esc_attr( $_POST['yim'] ) );
244
+ $changesSaved = 'yes';
245
+ }
246
+ }
247
+
248
+ if ($wppb_defaultOptions['jabber'] == 'show'){
249
+ $_POST['jabber'] = apply_filters('wppb_edit_profile_posted_jabber', $_POST['jabber']);
250
+ if ($wppb_defaultOptions['jabberRequired'] == 'yes'){
251
+ if ((trim($_POST['jabber']) != '') && isset($_POST['jabber'])){
252
+ update_user_meta( $current_user->id, 'jabber', esc_attr( $_POST['jabber'] ) );
253
+ $changesSaved = 'yes';
254
+ }
255
+ }else{
256
+ update_user_meta( $current_user->id, 'jabber', esc_attr( $_POST['jabber'] ) );
257
+ $changesSaved = 'yes';
258
+ }
259
+ }
260
+
261
+ if ($wppb_defaultOptions['bio'] == 'show'){
262
+ $_POST['description'] = apply_filters('wppb_edit_profile_posted_bio', $_POST['description']);
263
+ if ($wppb_defaultOptions['bioRequired'] == 'yes'){
264
+ if ((trim($_POST['description']) != '') && isset($_POST['description'])){
265
+ update_user_meta( $current_user->id, 'description', esc_attr( $_POST['description'] ) );
266
+ $changesSaved = 'yes';
267
+ }
268
+ }else{
269
+ update_user_meta( $current_user->id, 'description', esc_attr( $_POST['description'] ) );
270
+ $changesSaved = 'yes';
271
+ }
272
+ }
273
+
274
+ /* update the extra profile information */
275
+ $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/';
276
+ if (file_exists ( $wppb_premium.'extra.fields.php' )){
277
+ $wppbFetchArray = get_option('wppb_custom_fields');
278
+ foreach ( $wppbFetchArray as $key => $value){
279
+ switch ($value['item_type']) {
280
+ case "input":{
281
+ $_POST[$value['item_id'].$value['id']] = apply_filters('wppb_edit_profile_input_custom_field_'.$value['id'], $_POST[$value['item_id'].$value['id']]);
282
+ if (isset($value['item_required'])){
283
+ if ($value['item_required'] == 'yes'){
284
+ if (trim($_POST[$value['item_id'].$value['id']]) != '')
285
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
286
+ else
287
+ array_push($extraFieldsErrorHolder, $value['id']);
288
+ }else
289
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
290
+ }else
291
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
292
+
293
+ break;
294
+ }
295
+ case "hiddenInput":{
296
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
297
+
298
+ break;
299
+ }
300
+ case "checkbox":{
301
+ $checkboxOption = '';
302
+ $checkboxValue = explode(',', $value['item_options']);
303
+ foreach($checkboxValue as $thisValue){
304
+ $thisValue = str_replace(' ', '#@space@#', $thisValue); //we need to escape the space-codification we sent earlier in the post
305
+ if (isset($_POST[$thisValue.$value['id']])){
306
+ $localValue = str_replace('#@space@#', ' ', $_POST[$thisValue.$value['id']]);
307
+ $checkboxOption = $checkboxOption.$localValue.',';
308
+ }
309
+ }
310
+
311
+ if (isset($value['item_required'])){
312
+ if ($value['item_required'] == 'yes'){
313
+ if (trim($checkboxOption) != '')
314
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $checkboxOption ) );
315
+ else
316
+ array_push($extraFieldsErrorHolder, $value['id']);
317
+ }else
318
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $checkboxOption ) );
319
+ }else
320
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $checkboxOption ) );
321
+
322
+ break;
323
+ }
324
+ case "radio":{
325
+ if (isset($value['item_required'])){
326
+ if ($value['item_required'] == 'yes'){
327
+ if (trim($_POST[$value['item_id'].$value['id']]) != '')
328
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
329
+ else
330
+ array_push($extraFieldsErrorHolder, $value['id']);
331
+ }else
332
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
333
+ }else
334
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
335
+ break;
336
+ }
337
+ case "select":{
338
+ if (isset($value['item_required'])){
339
+ if ($value['item_required'] == 'yes'){
340
+ if (trim($_POST[$value['item_id'].$value['id']]) != '')
341
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
342
+ else
343
+ array_push($extraFieldsErrorHolder, $value['id']);
344
+ }else
345
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
346
+ }else
347
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
348
+ break;
349
+ }
350
+ case "countrySelect":{
351
+ if (isset($value['item_required'])){
352
+ if ($value['item_required'] == 'yes'){
353
+ if (trim($_POST[$value['item_id'].$value['id']]) != '')
354
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
355
+ else
356
+ array_push($extraFieldsErrorHolder, $value['id']);
357
+ }else
358
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
359
+ }else
360
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
361
+
362
+ break;
363
+ }
364
+ case "timeZone":{
365
+ if (isset($value['item_required'])){
366
+ if ($value['item_required'] == 'yes'){
367
+ if (trim($_POST[$value['item_id'].$value['id']]) != '')
368
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
369
+ else
370
+ array_push($extraFieldsErrorHolder, $value['id']);
371
+ }else
372
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
373
+ }else
374
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
375
+
376
+ break;
377
+ }
378
+ case "datepicker":{
379
+ if (isset($value['item_required'])){
380
+ if ($value['item_required'] == 'yes'){
381
+ if (trim($_POST[$value['item_id'].$value['id']]) != '')
382
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
383
+ else
384
+ array_push($extraFieldsErrorHolder, $value['id']);
385
+ }else
386
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
387
+ }else
388
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
389
+
390
+ break;
391
+ }
392
+ case "textarea":{
393
+ if (isset($value['item_required'])){
394
+ if ($value['item_required'] == 'yes'){
395
+ if (trim($_POST[$value['item_id'].$value['id']]) != '')
396
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
397
+ else
398
+ array_push($extraFieldsErrorHolder, $value['id']);
399
+ }else
400
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
401
+ }else
402
+ update_user_meta( $current_user->id, $value['item_metaName'], esc_attr( $_POST[$value['item_id'].$value['id']] ) );
403
+
404
+ break;
405
+ }
406
+ case "upload":{
407
+ $uploadedfile = $value['item_type'].$value['id'];
408
+
409
+ //get allowed file types
410
+ if (($value['item_options'] != NULL) || ($value['item_options'] != '')){
411
+ $allFiles = false;
412
+ $extensions = explode(',', $value['item_options']);
413
+ foreach($extensions as $key3 => $value3)
414
+ $extensions[$key3] = trim($value3);
415
+ }else
416
+ $allFiles = true;
417
+ //first we need to verify if we don't try to upload a 0b or 0 length file
418
+ if ( (basename( $_FILES[$uploadedfile]['name']) != '')){
419
+ //get this attachments extension
420
+ $thisFileExtStart = strrpos($_FILES[$uploadedfile]['name'], '.');
421
+ $thisFileExt = substr($_FILES[$uploadedfile]['name'], $thisFileExtStart);
422
+
423
+ if ($allFiles === false){
424
+ if (in_array($thisFileExt, $extensions)){
425
+ //second we need to verify if the uploaded file size is less then the set file size in php.ini
426
+ if (($_FILES[$uploadedfile]['size'] < WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE) && ($_FILES[$uploadedfile]['size'] !=0)){
427
+ //we need to prepare the basename of the file, so that ' becomes ` as ' gives an error
428
+ $fileName = basename( $_FILES[$uploadedfile]['name']);
429
+ $finalFileName = '';
430
+
431
+ for ($i=0; $i < strlen($fileName); $i++){
432
+ if ($fileName[$i] == "'")
433
+ $finalFileName .= '`';
434
+ else $finalFileName .= $fileName[$i];
435
+ }
436
+
437
+ //create the target path for uploading
438
+ $wpUploadPath = wp_upload_dir(); // Array of key => value pairs
439
+ $target_path = $wpUploadPath['basedir']."/profile_builder/attachments/";
440
+ $target_path = $target_path . 'userID_'.$current_user->id.'_attachment_'. $finalFileName;
441
+
442
+ if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)){
443
+ $upFile = $wpUploadPath['baseurl'].'/profile_builder/attachments/userID_'.$current_user->id.'_attachment_'. $finalFileName;
444
+ update_user_meta( $current_user->id, $value['item_metaName'], $upFile);
445
+ $pictureUpload = 'yes';
446
+ }else{
447
+ //insert the name of the file in an array so that in case an error comes up, we know which files we just uploaded
448
+ array_push($uploadName, basename( $_FILES[$uploadedfile]['name']));
449
+ }
450
+ }else{
451
+ //insert the name of the file in an array so that in case an error comes up, we know which files we just uploaded
452
+ array_push($uploadName, basename( $_FILES[$uploadedfile]['name']));
453
+ }
454
+ }else{
455
+ array_push($uploadExt, basename( $_FILES[$uploadedfile]['name']));
456
+ $allowedExtensions = '';
457
+ (int)$nrOfExt = count($extensions)-2;
458
+ foreach($extensions as $key4 => $value4){
459
+ $allowedExtensions .= $value4;
460
+ if ($key4 <= $nrOfExt)
461
+ $allowedExtensions .= ', ';
462
+
463
+ }
464
+ }
465
+ }else{
466
+ //second we need to verify if the uploaded file size is less then the set file size in php.ini
467
+ if (($_FILES[$uploadedfile]['size'] < WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE) && ($_FILES[$uploadedfile]['size'] !=0)){
468
+ //we need to prepare the basename of the file, so that ' becomes ` as ' gives an error
469
+ $fileName = basename( $_FILES[$uploadedfile]['name']);
470
+ $finalFileName = '';
471
+
472
+ for ($i=0; $i < strlen($fileName); $i++){
473
+ if ($fileName[$i] == "'")
474
+ $finalFileName .= '`';
475
+ else $finalFileName .= $fileName[$i];
476
+ }
477
+
478
+ //create the target path for uploading
479
+ $wpUploadPath = wp_upload_dir(); // Array of key => value pairs
480
+ $target_path = $wpUploadPath['basedir']."/profile_builder/attachments/";
481
+ $target_path = $target_path . 'userID_'.$current_user->id.'_attachment_'. $finalFileName;
482
+
483
+ if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)){
484
+ $upFile = $wpUploadPath['baseurl'].'/profile_builder/attachments/userID_'.$current_user->id.'_attachment_'. $finalFileName;
485
+ update_user_meta( $current_user->id, $value['item_metaName'], $upFile);
486
+ $pictureUpload = 'yes';
487
+ }else{
488
+ //insert the name of the file in an array so that in case an error comes up, we know which files we just uploaded
489
+ array_push($uploadName, basename( $_FILES[$uploadedfile]['name']));
490
+ }
491
+ }else{
492
+ //insert the name of the file in an array so that in case an error comes up, we know which files we just uploaded
493
+ array_push($uploadName, basename( $_FILES[$uploadedfile]['name']));
494
+ }
495
+ }
496
+ }
497
+ break;
498
+ }
499
+ case "avatar":{
500
+ $avatarUpload = 'no';
501
+ $uploadedfile = $value['item_type'].$value['id'];
502
+ $wpUploadPath = wp_upload_dir(); // Array of key => value pairs
503
+ $target_path_original = $wpUploadPath['basedir']."/profile_builder/avatars/";
504
+ $fileName = $_FILES[$uploadedfile]['name'];
505
+ $finalFileName = '';
506
+
507
+ for ($i=0; $i < strlen($fileName); $i++){
508
+ if ($fileName[$i] == "'")
509
+ $finalFileName .= '`';
510
+ elseif ($fileName[$i] == ' ')
511
+ $finalFileName .= '_';
512
+ else $finalFileName .= $fileName[$i];
513
+ }
514
+
515
+ $fileName = $finalFileName;
516
+
517
+ $target_path = $target_path_original . 'userID_'.$current_user->id.'_originalAvatar_'. $fileName;
518
+
519
+ /* when trying to upload file, be sure it's one of the accepted image file-types */
520
+ 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'] < WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE) && ($_FILES[$uploadedfile]['size'] !=0)) ){
521
+ $avatarUpload = 'yes';
522
+ $wp_filetype = wp_check_filetype(basename( $_FILES[$uploadedfile]['name']), null );
523
+ $attachment = array(
524
+ 'post_mime_type' => $wp_filetype['type'],
525
+ 'post_title' => $fileName,
526
+ 'post_content' => '',
527
+ 'post_status' => 'inherit'
528
+ );
529
+
530
+
531
+ $attach_id = wp_insert_attachment( $attachment, $target_path);
532
+
533
+ $upFile = image_downsize( $attach_id, 'thumbnail' );
534
+ $upFile = $upFile[0];
535
+
536
+ //if file upload succeded
537
+ if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)){
538
+ update_user_meta( $current_user->id, $value['item_metaName'], $upFile);
539
+ update_user_meta( $current_user->id, 'resized_avatar_'.$value['id'], '');
540
+
541
+ }else $avatarUpload = 'no';
542
+ }elseif ( (($_FILES[$uploadedfile]['size'] > WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE) || ($_FILES[$uploadedfile]['size'] == 0)) && ($fileName != '') )
543
+ $avatarUpload = 'no';
544
+ elseif ($fileName == '')
545
+ $avatarUpload = 'yes';
546
+ break;
547
+ }
548
+ }
549
+ }
550
+ }
551
+
552
+ }
553
+
554
+ ?>
555
+ <div class="wppb_holder" id="wppb_modify">
556
+ <?php
557
+ if ( !is_user_logged_in() ) :
558
+ $editProfileFilterArray['notLoggedIn'] = '
559
+ <p class="warning">'. __('You must be logged in to edit your profile.', 'profilebuilder') .'</p><!-- .warning -->';
560
+ $editProfileFilterArray['notLoggedIn'] = apply_filters('wppb_edit_profile_user_not_logged_in', $editProfileFilterArray['notLoggedIn']);
561
+ echo $editProfileFilterArray['notLoggedIn'];
562
+
563
+ else :
564
+ {
565
+ /* messages for the the delete avatar/attachment */
566
+ if (isset($_GET['fileType'])){
567
+ if ($_GET['fileType'] == 'avatar'){
568
+ $editProfileFilterArray['avatarChangesSaved'] = '
569
+ <p class="changes-saved">'. __('The avatar was successfully deleted.', 'profilebuilder') .'</p><!-- .changes-saved -->';
570
+ $editProfileFilterArray['avatarChangesSaved'] = apply_filters('wppb_edit_profile_avatar_changes_saved', $editProfileFilterArray['avatarChangesSaved']);
571
+ echo $editProfileFilterArray['avatarChangesSaved'];
572
+ unset($_GET['fileType']);
573
+ }elseif ($_GET['fileType'] == 'attachment'){
574
+ $editProfileFilterArray['attachmentChangesSaved'] = '
575
+ <p class="changes-saved">'.
576
+ __('The attachment', 'profilebuilder') .' "'. $_GET['fileName'] .'" '. __('was successfully deleted.', 'profilebuilder') .'
577
+ </p><!-- .changes-saved -->';
578
+ $editProfileFilterArray['attachmentChangesSaved'] = apply_filters('wppb_edit_profile_attachment_changes_saved', $editProfileFilterArray['attachmentChangesSaved']);
579
+ echo $editProfileFilterArray['attachmentChangesSaved'];
580
+ unset($_GET['fileType']);
581
+ unset($_GET['fileName']);
582
+ }
583
+ }
584
+
585
+ /* all the other messages/errors */
586
+ $nrOfBadUploads = 0;
587
+ $nrOfBadUploads = count($uploadName);
588
+ $nrOfBadExtUploads = count($uploadExt);
589
+ if (($changesSaved == 'yes') && ($changesSavedNoMatchingPass == 'no') && ($changesSavedNoPass == 'no') && ($changesSavedNoEmail == 'no') && ($changesSavedNoEmailExist == 'no') && ($avatarUpload == 'yes') && ($nrOfBadUploads == 0) && ($nrOfBadExtUploads == 0)){
590
+ $editProfileFilterArray['allChangesSaved'] = '
591
+ <p class="changes-saved">'. __('The changes have been successfully saved.', 'profilebuilder') .'</p><!-- .changes-saved -->';
592
+ $editProfileFilterArray['allChangesSaved'] = apply_filters('wppb_edit_profile_all_changes_saved', $editProfileFilterArray['allChangesSaved']);
593
+ echo $editProfileFilterArray['allChangesSaved'];
594
+ }
595
+ elseif (($changesSaved == 'yes') && ($changesSavedNoEmailExist == 'yes') && ($previousError == 'no')){
596
+ $editProfileFilterArray['allChangesSavedExceptExistingEmail'] = '
597
+ <p class="semi-saved"> '.
598
+ __('The email address you entered is already registered to a different user.', 'profilebuilder') .'<br/>'. __('The email address was', 'profilebuilder') .' <span class="error">'. __('NOT', 'profilebuilder') .'</span> '. __('updated along with the rest of the information.', 'profilebuilder') .'
599
+ </p>';
600
+ $editProfileFilterArray['allChangesSavedExceptExistingEmail'] = apply_filters('wppb_edit_profile_all_changes_saved_except_existing_email', $editProfileFilterArray['allChangesSavedExceptExistingEmail']);
601
+ echo $editProfileFilterArray['allChangesSavedExceptExistingEmail'];
602
+ $previousError = 'yes';
603
+ }
604
+
605
+ if (($changesSaved == 'yes') && ($changesSavedNoEmail == 'yes') && ($previousError == 'no')){
606
+ $editProfileFilterArray['allChangesSavedExceptInvalidEmail'] = '
607
+ <p class="semi-saved"> '.
608
+ __('The email address you entered is invalid.', 'profilebuilder') .'<br/>'. __('The email address was', 'profilebuilder') .' <span class="error">'. __('NOT', 'profilebuilder') .'</span> '. __('updated along with the rest of the information.', 'profilebuilder') .'
609
+ </p>';
610
+ $editProfileFilterArray['allChangesSavedExceptInvalidEmail'] = apply_filters('wppb_edit_profile_all_changes_saved_except_invalid_email', $editProfileFilterArray['allChangesSavedExceptInvalidEmail']);
611
+ echo $editProfileFilterArray['allChangesSavedExceptInvalidEmail'];
612
+ $previousError = 'yes';
613
+ }
614
+
615
+ if (($changesSaved == 'yes') && ($changesSavedNoMatchingPass == 'yes') && ($previousError == 'no')){
616
+ $editProfileFilterArray['allChangesSavedMismatchedPass'] = '
617
+ <p class="semi-saved">';
618
+ __('The passwords you entered do not match.', 'profilebuilder') .'<br/>'. __('The password was', 'profilebuilder') .' <span class="error">'. __('NOT', 'profilebuilder') .'</span> '. __('updated along with the rest of the information.', 'profilebuilder') .'
619
+ </p>';
620
+ $editProfileFilterArray['allChangesSavedMismatchedPass'] = apply_filters('wppb_edit_profile_all_changes_saved_except_mismatch_password', $editProfileFilterArray['allChangesSavedMismatchedPass']);
621
+ echo $editProfileFilterArray['allChangesSavedMismatchedPass'];
622
+ $previousError = 'yes';
623
+ }
624
+ if (($changesSaved == 'yes') && ($changesSavedNoPass == 'yes') && ($previousError == 'no')){
625
+ $editProfileFilterArray['allChangesSavedUncompletedPass'] = '
626
+ <p class="semi-saved">'.
627
+ __('You didn\'t complete both password fields.', 'profilebuilder') .'<br/>'. __('The password was', 'profilebuilder') .' <span class="error">'. __('NOT', 'profilebuilder') .'</span> '. __('updated along with the rest of the information.', 'profilebuilder') .'
628
+ </p>';
629
+ $editProfileFilterArray['allChangesSavedUncompletedPass'] = apply_filters('wppb_edit_profile_all_changes_saved_except_uncompleted_password', $editProfileFilterArray['allChangesSavedUncompletedPass']);
630
+ echo $editProfileFilterArray['allChangesSavedUncompletedPass'];
631
+ $previousError = 'yes';
632
+ }
633
+ if ($allRequiredCompleted == 'no'){
634
+ $editProfileFilterArray['errorSavingChanges'] = '<p class="error">'.$errorMessage.'<br/>'. __('Your profile was NOT updated!', 'profilebuilder').'</p><!-- .error -->';
635
+ $editProfileFilterArray['errorSavingChanges'] = apply_filters('wppb_edit_profile_error_saving_changes', $editProfileFilterArray['errorSavingChanges']);
636
+ echo $editProfileFilterArray['errorSavingChanges'];
637
+ }
638
+ $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/';
639
+ if (file_exists ( $wppb_premium.'extra.fields.php' )){
640
+ if (($changesSaved == 'yes') && ($nrOfBadUploads > 0) && ($previousError == 'no')){
641
+ $lastOne = 0;
642
+ $editProfileFilterArray['errorUploadingAttachments'] = '
643
+ <p class="semi-saved">'. __('There was an error while trying to upload the following attachments:', 'profilebuilder') .'<br/>
644
+ <span class="error">';
645
+ foreach ($uploadName as $key => $name){
646
+ $lastOne++;
647
+ $editProfileFilterArray['errorUploadingAttachments'] .= $name;
648
+ if ($nrOfBadUploads-$lastOne > 0)
649
+ $editProfileFilterArray['errorUploadingAttachments'] .= ';<span style="padding-left:10px"></span>';
650
+ }
651
+ $editProfileFilterArray['errorUploadingAttachments'] .= '
652
+ </span><br/>'.
653
+ __('Possible cause: the size was bigger than', 'profilebuilder') .' '.WPPB_SERVER_MAX_UPLOAD_SIZE_MEGA.'b.<br/>'. __('The listed attachements were', 'profilebuilder') .' <span class="error">'. __('NOT', 'profilebuilder') .'</span> '. __('updated along with the rest of the information.', 'profilebuilder') .'
654
+ </p>';
655
+ $editProfileFilterArray['errorUploadingAttachments'] = apply_filters('wppb_edit_profile_error_uploading_attachments', $editProfileFilterArray['errorUploadingAttachments']);
656
+ echo $editProfileFilterArray['errorUploadingAttachments'];
657
+ $previousError = 'yes';
658
+ }if (($changesSaved == 'yes') && ($avatarUpload == 'no') && ($previousError == 'no')){
659
+ $editProfileFilterArray['errorUploadingAvatar'] = '
660
+ <p class="semi-saved">'.
661
+ __('There was an error while trying to upload your avatar picture.', 'profilebuilder') .'<br/>'. __('Possible cause: size/incorrect file-type.', 'profilebuilder') .'<br/>'. __('The avatar was', 'profilebuilder') .' <span class="error">'. __('NOT', 'profilebuilder') .'</span> '. __('updated along with the rest of the information.', 'profilebuilder') .'
662
+ </p>';
663
+ $editProfileFilterArray['errorUploadingAvatar'] = apply_filters('wppb_edit_profile_error_uploading_avatar', $editProfileFilterArray['errorUploadingAvatar']);
664
+ echo $editProfileFilterArray['errorUploadingAvatar'];
665
+ $previousError = 'yes';
666
+ }if (($changesSaved == 'yes') && ($nrOfBadExtUploads != 0) && ($previousError == 'no')){
667
+ $editProfileFilterArray['errorUploadingAttachmentExts'] = '
668
+ <p class="semi-saved">'.
669
+ __('There was an error while trying to upload the following attachment(s)', 'profilebuilder') .': <span class="error">';
670
+ foreach ($uploadExt as $key5 => $name5){
671
+ $lastOne++;
672
+ $editProfileFilterArray['errorUploadingAttachmentExts'] .= $name5;
673
+ if ($nrOfBadExtUploads-$lastOne > 0)
674
+ $editProfileFilterArray['errorUploadingAttachmentExts'] .= ';<span style="padding-left:10px"></span>';
675
+ }
676
+ $editProfileFilterArray['errorUploadingAttachmentExts'] .= '</span><br/>'. __('Only files with the following extension(s) can be uploaded:', 'profilebuilder') .' <span class="error">'.$allowedExtensions.'</span><br/>'. __('This file was', 'profilebuilder') .' <span class="error">'. __('NOT', 'profilebuilder') .'</span> '. __('updated along with the rest of the information.', 'profilebuilder') .'
677
+ </p>';
678
+ $editProfileFilterArray['errorUploadingAttachmentExts'] = apply_filters('wppb_edit_profile_error_uploading_attachment', $editProfileFilterArray['errorUploadingAttachmentExts']);
679
+ echo $editProfileFilterArray['errorUploadingAttachmentExts'];
680
+ $previousError = 'yes';
681
+ }
682
+ }
683
+ }
684
+
685
+ /* use this action hook to add extra content before the edit profile form. */
686
+ do_action( 'wppb_before_edit_profile_fields' );
687
+ ?>
688
+
689
+ <form enctype="multipart/form-data" method="post" id="edituser" class="user-forms" action="<?php the_permalink(); ?>">
690
+ <?php
691
+ echo '<input type="hidden" name="MAX_FILE_SIZE" value="'.WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE.'" /><!-- set the MAX_FILE_SIZE to the server\'s current max upload size in bytes -->';
692
+
693
+ $editProfileFilterArray2['contentName1'] = '<p class="nameHeader"><strong>'. __('Name', 'profilebuilder') .'</strong></p>';
694
+ $editProfileFilterArray2['contentName1'] = apply_filters('wppb_edit_profile_content_name1', $editProfileFilterArray2['contentName1']);
695
+
696
+ if ($wppb_defaultOptions['username'] == 'show'){
697
+ $editProfileFilterArray2['contentName2'] = '
698
+ <p class="username">
699
+ <label for="user_login">'. __('Username', 'profilebuilder') .'</label>
700
+ <input class="text-input" name="user_login" type="text" id="user_login" value="'. get_the_author_meta( 'user_login', $current_user->id ) .'" disabled="disabled"/> <span class="wppb-description-delimiter"> '. __('Usernames cannot be changed.', 'profilebuilder') .'</span>
701
+ </p><!-- .first_name -->';
702
+ $editProfileFilterArray2['contentName2'] = apply_filters('wppb_edit_profile_content_name2', $editProfileFilterArray2['contentName2']);
703
+ }
704
+
705
+ if ($wppb_defaultOptions['firstname'] == 'show'){
706
+ $errorVar = '';
707
+ $errorMark = '';
708
+ if ($wppb_defaultOptions['firstnameRequired'] == 'yes'){
709
+ $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
710
+ if (isset($_POST['first_name'])){
711
+ if (trim($_POST['first_name']) == ''){
712
+ $errorMark = '<img src="'.WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator)."/>';
713
+ $errorVar = ' errorHolder';
714
+ }
715
+ }
716
+ }
717
+ $editProfileFilterArray2['contentName3'] = '
718
+ <p class="first_name'.$errorVar.'">
719
+ <label for="first_name">'. __('First Name', 'profilebuilder') .$errorMark.'</label>
720
+ <input class="text-input" name="first_name" type="text" id="first_name" value="'. get_the_author_meta( 'first_name', $current_user->id ) .'" />
721
+ </p><!-- .first_name -->';
722
+ $editProfileFilterArray2['contentName3'] = apply_filters('wppb_edit_profile_content_name3', $editProfileFilterArray2['contentName3']);
723
+ }
724
+
725
+ if ($wppb_defaultOptions['lastname'] == 'show'){
726
+ $errorVar = '';
727
+ $errorMark = '';
728
+ if ($wppb_defaultOptions['lastnameRequired'] == 'yes'){
729
+ $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
730
+ if (isset($_POST['last_name'])){
731
+ if (trim($_POST['last_name']) == ''){
732
+ $errorMark = '<img src="'.WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator)."/>';
733
+ $errorVar = ' errorHolder';
734
+ }
735
+ }
736
+ }
737
+ $editProfileFilterArray2['contentName4'] = '
738
+ <p class="last_name'.$errorVar.'">
739
+ <label for="last_name">'. __('Last Name', 'profilebuilder') .$errorMark.'</label>
740
+ <input class="text-input" name="last_name" type="text" id="last_name" value="'. get_the_author_meta( 'last_name', $current_user->id ) .'" />
741
+ </p><!-- .last_name -->';
742
+ $editProfileFilterArray2['contentName4'] = apply_filters('wppb_edit_profile_content_name4', $editProfileFilterArray2['contentName4']);
743
+ }
744
+
745
+ if ($wppb_defaultOptions['nickname'] == 'show'){
746
+ $errorVar = '';
747
+ $errorMark = '';
748
+ if ($wppb_defaultOptions['nicknameRequired'] == 'yes'){
749
+ $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
750
+ if (isset($_POST['nickname'])){
751
+ if (trim($_POST['nickname']) == ''){
752
+ $errorMark = '<img src="'.WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator)."/>';
753
+ $errorVar = ' errorHolder';
754
+ }
755
+ }
756
+ }
757
+ $editProfileFilterArray2['contentName5'] = '
758
+ <p class="nickname'.$errorVar.'">
759
+ <label for="nickname">'. __('Nickname', 'profilebuilder') .$errorMark.'</label>
760
+ <input class="text-input" name="nickname" type="text" id="nickname" value="'. get_the_author_meta( 'nickname', $current_user->id ) .'" />
761
+ </p><!-- .nickname -->';
762
+ $editProfileFilterArray2['contentName5'] = apply_filters('wppb_edit_profile_content_name5', $editProfileFilterArray2['contentName5']);
763
+ }
764
+
765
+ if ($wppb_defaultOptions['dispname'] == 'show'){
766
+ $errorVar = '';
767
+ $errorMark = '';
768
+ if ($wppb_defaultOptions['dispnameRequired'] == 'yes'){
769
+ $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
770
+ if (isset($_POST['display_name'])){
771
+ if (trim($_POST['display_name']) == ''){
772
+ $errorMark = '<img src="'.WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator)."/>';
773
+ $errorVar = ' errorHolder';
774
+ }
775
+ }
776
+ }
777
+
778
+ $editProfileFilterArray2['displayName'] = '
779
+ <p class="display_name'.$errorVar.'">
780
+ <label for="display_name">'. __('Display name publicly as', 'profilebuilder') .$errorMark.'</label>
781
+ <select name="display_name" id="display_name">';
782
+ $public_display = array();
783
+ $public_display['display_username'] = get_the_author_meta('user_login', $current_user->id);
784
+ $thisFirstName = get_the_author_meta('first_name', $current_user->id);
785
+ if ( !empty($thisFirstName))
786
+ $public_display['display_firstname'] = get_the_author_meta('first_name', $current_user->id);
787
+ $thisLastName = get_the_author_meta('last_name', $current_user->id);
788
+ if ( !empty($thisLastName))
789
+ $public_display['display_lastname'] = get_the_author_meta('last_name', $current_user->id);
790
+ $public_display['display_nickname'] = get_the_author_meta('nickname', $current_user->id);
791
+ if ( !empty($thisFirstName) && !empty($thisLastName) ) {
792
+ $public_display['display_firstlast'] = $thisFirstName . ' ' . $thisLastName;
793
+ $public_display['display_lastfirst'] = $thisLastName . ' ' . $thisFirstName;
794
+ }
795
+ $thisDisplayName = get_the_author_meta('display_name', $current_user->id);
796
+ if ( !in_array( $thisDisplayName, $public_display ) ) // Only add this if it isn't duplicated elsewhere
797
+ $public_display = array( 'display_displayname' => $thisDisplayName ) + $public_display;
798
+ $public_display = array_map( 'trim', $public_display );
799
+ foreach ( $public_display as $id => $item ) {
800
+ $editProfileFilterArray2['displayName'] .= '<option id="'.$id.'" value="'.$item.'"';
801
+ if ($thisDisplayName == $item)
802
+ $editProfileFilterArray2['displayName'] .= ' selected';
803
+ $editProfileFilterArray2['displayName'] .= '>'.$item.'</option>';
804
+ }
805
+ $editProfileFilterArray2['displayName'] .= '
806
+ </select>
807
+ </p><!-- .display_name -->';
808
+
809
+ $editProfileFilterArray2['displayName'] = apply_filters('wppb_edit_profile_display_name', $editProfileFilterArray2['displayName']);
810
+ }
811
+
812
+ $editProfileFilterArray2['contentInfo1'] = '<p class="contactInfoHeader"><strong>'. __('Contact Info', 'profilebuilder') .'</strong></p>';
813
+ $editProfileFilterArray2['contentInfo1'] = apply_filters('wppb_edit_profile_content_info1', $editProfileFilterArray2['contentInfo1']);
814
+
815
+ if ($wppb_defaultOptions['email'] == 'show'){
816
+ $errorVar = '';
817
+ $errorMark = '';
818
+ if ($wppb_defaultOptions['emailRequired'] == 'yes'){
819
+ $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
820
+ if (isset($_POST['email'])){
821
+ if (trim($_POST['email']) == ''){
822
+ $errorMark = '<img src="'.WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator)."/>';
823
+ $errorVar = ' errorHolder';
824
+ }
825
+ }
826
+ }
827
+ $editProfileFilterArray2['contentInfo2'] = '
828
+ <p class="form-email'.$errorVar.'">
829
+ <label for="email">'. __('E-mail', 'profilebuilder') .$errorMark.'</label>
830
+ <input class="text-input" name="email" type="text" id="email" value="'. get_the_author_meta( 'user_email', $current_user->id ) .'" />
831
+ <span class="wppb-description-delimiter">'. __('(required)', 'profilebuilder') .'</span>
832
+ </p><!-- .form-email -->';
833
+ $editProfileFilterArray2['contentInfo2'] = apply_filters('wppb_edit_profile_content_info2', $editProfileFilterArray2['contentInfo2']);
834
+ }
835
+
836
+ if ($wppb_defaultOptions['website'] == 'show'){
837
+ $errorVar = '';
838
+ $errorMark = '';
839
+ if ($wppb_defaultOptions['websiteRequired'] == 'yes'){
840
+ $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
841
+ if ((trim($_POST['website']) == '') && isset($_POST['website'])){
842
+ $errorMark = '<img src="'.WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator)."/>';
843
+ $errorVar = ' errorHolder';
844
+ }
845
+ }
846
+ $editProfileFilterArray2['contentInfo3'] = '
847
+ <p class="form-website'.$errorVar.'">
848
+ <label for="website">'. __('Website', 'profilebuilder') .$errorMark.'</label>
849
+ <input class="text-input" name="website" type="text" id="website" value="'. get_the_author_meta( 'user_url', $current_user->id ) .'" />
850
+ </p><!-- .form-website -->';
851
+ $editProfileFilterArray2['contentInfo3'] = apply_filters('wppb_edit_profile_content_info3', $editProfileFilterArray2['contentInfo3']);
852
+ }
853
+
854
+ if ($wppb_defaultOptions['aim'] == 'show'){
855
+ $errorVar = '';
856
+ $errorMark = '';
857
+ if ($wppb_defaultOptions['aimRequired'] == 'yes'){
858
+ $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
859
+ if ((trim($_POST['aim']) == '') && isset($_POST['aim'])){
860
+ $errorMark = '<img src="'.WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator)."/>';
861
+ $errorVar = ' errorHolder';
862
+ }
863
+ }
864
+ $editProfileFilterArray2['contentInfo4'] = '
865
+ <p class="form-aim'.$errorVar.'">
866
+ <label for="aim">'. __('AIM', 'profilebuilder') .'</label>
867
+ <input class="text-input" name="aim" type="text" id="aim" value="'. get_the_author_meta( 'aim', $current_user->id ) .'" />
868
+ </p><!-- .form-aim -->';
869
+ $editProfileFilterArray2['contentInfo4'] = apply_filters('wppb_edit_profile_content_info4', $editProfileFilterArray2['contentInfo4']);
870
+ }
871
+
872
+ if ($wppb_defaultOptions['yahoo'] == 'show'){
873
+ $errorVar = '';
874
+ $errorMark = '';
875
+ if ($wppb_defaultOptions['yahooRequired'] == 'yes'){
876
+ $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
877
+ if ((trim($_POST['yim']) == '') && isset($_POST['yim'])){
878
+ $errorMark = '<img src="'.WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator)."/>';
879
+ $errorVar = ' errorHolder';
880
+ }
881
+ }
882
+ $editProfileFilterArray2['contentInfo5'] = '
883
+ <p class="form-yim'.$errorVar.'">
884
+ <label for="yim">'. __('Yahoo IM', 'profilebuilder') .$errorMark.'</label>
885
+ <input class="text-input" name="yim" type="text" id="yim" value="'. get_the_author_meta( 'yim', $current_user->id ) .'" />
886
+ </p><!-- .form-yim -->';
887
+ $editProfileFilterArray2['contentInfo5'] = apply_filters('wppb_edit_profile_content_info5', $editProfileFilterArray2['contentInfo5']);
888
+ }
889
+
890
+ if ($wppb_defaultOptions['jabber'] == 'show'){
891
+ $errorVar = '';
892
+ $errorMark = '';
893
+ if ($wppb_defaultOptions['jabberRequired'] == 'yes'){
894
+ $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
895
+ if ((trim($_POST['jabber']) == '') && isset($_POST['jabber'])){
896
+ $errorMark = '<img src="'.WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator)."/>';
897
+ $errorVar = ' errorHolder';
898
+ }
899
+ }
900
+ $editProfileFilterArray2['contentInfo6'] = '
901
+ <p class="form-jabber'.$errorVar.'">
902
+ <label for="jabber">'. __('Jabber / Google Talk', 'profilebuilder') .$errorMark.'</label>
903
+ <input class="text-input" name="jabber" type="text" id="jabber" value="'. get_the_author_meta( 'jabber', $current_user->id ) .'" />
904
+ </p><!-- .form-jabber -->';
905
+ $editProfileFilterArray2['contentInfo6'] = apply_filters('wppb_edit_profile_content_info6', $editProfileFilterArray2['contentInfo6']);
906
+ }
907
+
908
+ $editProfileFilterArray2['aboutYourself1'] = '<p class="aboutYourselfHeader"><strong>'. __('About Yourself', 'profilebuilder') .'</strong></p>';
909
+ $editProfileFilterArray2['aboutYourself1'] = apply_filters('wppb_edit_profile_content_about_yourself1', $editProfileFilterArray2['aboutYourself1']);
910
+
911
+ if ($wppb_defaultOptions['bio'] == 'show'){
912
+ $errorVar = '';
913
+ $errorMark = '';
914
+ if ($wppb_defaultOptions['bioRequired'] == 'yes'){
915
+ $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
916
+ if ((trim($_POST['description']) == '') && isset($_POST['description'])){
917
+ $errorMark = '<img src="'.WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field wasn\'t updated because you entered and empty string (It was marked as required by the administrator)."/>';
918
+ $errorVar = ' errorHolder';
919
+ }
920
+ }
921
+ $editProfileFilterArray2['aboutYourself2'] = '
922
+ <p class="form-description'.$errorVar.'">
923
+ <label for="description">'. __('Biographical Info', 'profilebuilder') .$errorMark.'</label>
924
+ <textarea class="text-input" name="description" id="description" rows="5" cols="30">'. get_the_author_meta( 'description', $current_user->id ) .'</textarea>
925
+ </p><!-- .form-description -->';
926
+ $editProfileFilterArray2['aboutYourself2'] = apply_filters('wppb_edit_profile_content_about_yourself2', $editProfileFilterArray2['aboutYourself2']);
927
+ }
928
+
929
+ if ($wppb_defaultOptions['password'] == 'show'){
930
+
931
+ $editProfileFilterArray2['aboutYourself3'] = '
932
+ <p class="form-password">
933
+ <label for="pass1">'. __('New Password', 'profilebuilder') .'</label>
934
+ <input class="text-input" name="pass1" type="password" id="pass1" />
935
+ </p><!-- .form-password -->
936
+
937
+ <p class="form-password'.$errorVar.'">
938
+ <label for="pass2">'. __('Repeat Password', 'profilebuilder') .$errorMark.'</label>
939
+ <input class="text-input" name="pass2" type="password" id="pass2" />
940
+ </p><!-- .form-password -->';
941
+ $editProfileFilterArray2['aboutYourself3'] = apply_filters('wppb_edit_profile_content_about_yourself3', $editProfileFilterArray2['aboutYourself3']);
942
+ }
943
+
944
+
945
+ $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/';
946
+ if (file_exists ( $wppb_premium.'extra.fields.php' )){
947
+ require_once($wppb_premium.'extra.fields.php');
948
+
949
+ $page = 'edit_profile';
950
+ $returnedValue = wppb_extra_fields($current_user->id, $extraFieldsErrorHolder, $editProfileFilterArray2, $page, $error, $_POST);
951
+
952
+ //copy over extra fields to the rest of the fieldso on the edit profile
953
+ foreach($returnedValue as $key => $value)
954
+ $editProfileFilterArray2[$key] = $value;
955
+ }
956
+
957
+ /* additional filter, just in case it is needed */
958
+ $editProfileFilterArray2['extraEditProfileFilter'] = '';
959
+ $editProfileFilterArray2['extraEditProfileFilter'] = apply_filters('extraEditProfileFilter', $editProfileFilterArray2['extraEditProfileFilter']);
960
+ /* END additional filter, just in case it is needed */
961
+
962
+
963
+ $editProfileFilterArray2 = apply_filters('wppb_edit_profile', $editProfileFilterArray2);
964
+ foreach ($editProfileFilterArray2 as $key => $value)
965
+ echo $value;
966
+ ?>
967
+
968
+ <p class="form-submit">
969
+ <input name="updateuser" type="submit" id="updateuser" class="submit button" value="<?php _e('Update', 'profilebuilder'); ?>" />
970
+ <?php// wp_nonce_field( 'update-user' ) ?>
971
+ <input name="action" type="hidden" id="action" value="update-user" />
972
+ </p><!-- .form-submit -->
973
+ <?php wp_nonce_field('verify_edit_user','edit_nonce_field'); ?>
974
+ </form><!-- #edituser -->
975
+
976
+ <?php endif; ?>
977
+ <?php /* use this action hook to add extra content after the edit profile form. */ ?>
978
+ <?php do_action( 'wppb_after_edit_profile_fields' ); ?>
979
+
980
+ </div>
981
+
982
+ <?php
983
+
984
+ $output = ob_get_contents();
985
+ ob_end_clean();
986
+
987
+ return $output;
988
+ }
989
  ?>
front-end/wppb.login.php CHANGED
@@ -1,167 +1,172 @@
1
- <?php
2
- if(!function_exists('wppb_curpageurl')){
3
- function wppb_curpageurl() {
4
- $pageURL = 'http';
5
- if ((isset($_SERVER["HTTPS"])) && ($_SERVER["HTTPS"] == "on")) {
6
- $pageURL .= "s";
7
- }
8
- $pageURL .= "://";
9
- if ($_SERVER["SERVER_PORT"] != "80") {
10
- $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
11
- } else {
12
- $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
13
- }
14
- return $pageURL;
15
- }
16
- }
17
-
18
- /* wp_signon can only be executed before anything is outputed in the page because of that we're adding it to the init hook */
19
- global $wppb_login;
20
- $wppb_login = false;
21
-
22
- function wppb_signon(){
23
- if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'log-in' && wp_verify_nonce($_POST['login_nonce_field'],'verify_true_login')) :
24
- global $error;
25
- global $wppb_login;
26
-
27
- if (isset($_POST['remember-me']))
28
- $remember = $_POST['remember-me'];
29
- else $remember = false;
30
- $wppb_login = wp_signon( array( 'user_login' => $_POST['user-name'], 'user_password' => $_POST['password'], 'remember' => $_POST['remember-me'] ), false );
31
- endif;
32
- }
33
- add_action('init', 'wppb_signon');
34
-
35
- function wppb_front_end_login(){
36
- $loginFilterArray = array();
37
- ob_start();
38
- global $wppb_login;
39
-
40
- echo '<div class="wppb_holder" id="wppb_login">';
41
-
42
- if ( is_user_logged_in() ) : // Already logged in
43
- global $user_ID;
44
- $wppb_user = get_userdata( $user_ID );
45
- if($wppb_user->display_name == ''){
46
- $wppb_user->display_name = $wppb_user->user_login;
47
- }
48
-
49
- ?>
50
- <?php
51
- $loginFilterArray['loginMessage1'] = '
52
- <p class="alert">'.
53
- __('You are currently logged in as', 'profilebuilder').' <a href="'.$authorPostsUrl = get_author_posts_url( $wppb_user->ID ).'" title="'.$wppb_user->display_name.'">'.$wppb_user->display_name.'</a>.
54
- <a href="'.wp_logout_url( get_permalink() ).'" title="'. __('Log out of this account', 'profilebuilder').'">'. __('Log out', 'profilebuilder').' &raquo;</a>
55
- </p><!-- .alert-->';
56
-
57
- $loginFilterArray['loginMessage1'] = apply_filters('wppb_login_login_message1', $loginFilterArray['loginMessage1']);
58
- echo $loginFilterArray['loginMessage1'];
59
- ?>
60
-
61
- <?php elseif ( $wppb_login->ID ) : // Successful login ?>
62
- <?php
63
- //$wppb_login = get_userdata( $wppb_login->ID );
64
- if($wppb_login->display_name == ''){
65
- $wppb_login->display_name = $wppb_login->user_login;
66
- }
67
-
68
- ?>
69
-
70
- <?php
71
- $loginFilterArray['loginMessage2'] = '
72
- <p class="success">'.
73
- __('You have successfully logged in as', 'profilebuilder').' <a href="'.$authorPostsUrl = get_author_posts_url( $wppb_login->ID ).'" title="'.$wppb_login->display_name.'">'.$wppb_login->display_name.'</a>.
74
- </p><!-- .success-->';
75
-
76
- $loginFilterArray['loginMessage2'] = apply_filters('wppb_login_login_message2', $loginFilterArray['loginMessage2']);
77
- echo $loginFilterArray['loginMessage2'];
78
- ?>
79
-
80
-
81
- <?php
82
- $permaLnk2 = get_permalink();
83
- $wppb_addons = wppb_plugin_dir . '/premium/addon/';
84
- if (file_exists ( $wppb_addons.'addon.php' )){
85
- //check to see if the redirecting addon is present and activated
86
- $wppb_premium_addon_settings = get_option('wppb_premium_addon_settings'); //fetch the descriptions array
87
- if ($wppb_premium_addon_settings['customRedirect'] == 'show'){
88
- //check to see if the redirect location is not an empty string and is activated
89
- $customRedirectSettings = get_option('customRedirectSettings');
90
- if ((trim($customRedirectSettings['afterLoginTarget']) != '') && ($customRedirectSettings['afterLogin'] == 'yes')){
91
- $permaLnk2 = trim($customRedirectSettings['afterLoginTarget']);
92
- $findHttp = strpos($permaLnk2, 'http');
93
- if ($findHttp === false)
94
- $permaLnk2 = 'http://'. $permaLnk2;
95
- }
96
- }
97
- }
98
-
99
- $loginFilterArray['redirectMessage'] = '
100
- <font color="black">'. __('You will soon be redirected automatically. If you see this page for more than 1 second, please click', 'profilebuilder').' <a href="'.$permaLnk2.'">'. __('here', 'profilebuilder').'</a>.<meta http-equiv="Refresh" content="1;url='.$permaLnk2.'" /></font><br/><br/>';
101
- $loginFilterArray['redirectMessage'] = apply_filters('wppb_login_redirect_message', $loginFilterArray['redirectMessage']);
102
- echo $loginFilterArray['redirectMessage'];
103
- ?>
104
- <?php else : // Not logged in ?>
105
-
106
- <?php if (!empty( $_POST['action'] )): ?>
107
- <p class="error">
108
- <?php if ( trim($_POST['user-name']) == '') echo '<strong>'. __('ERROR:','profilebuilder').'</strong> '. __('The username field is empty', 'profilebuilder').'. '; ?>
109
- <?php if ( is_wp_error($wppb_login) ) echo $wppb_login->get_error_message();?>
110
- </p><!-- .error -->
111
- <?php endif; ?>
112
-
113
- <?php /* use this action hook to add extra content before the login form. */ ?>
114
- <?php do_action( 'wppb_before_login' ); ?>
115
-
116
- <form action="<?php wppb_curpageurl(); ?>" method="post" class="sign-in">
117
- <p class="login-form-username">
118
- <label for="user-name"><?php _e('Username', 'profilebuilder'); ?></label>
119
- <?php
120
- if (isset($_POST['user-name']))
121
- $userName = esc_html( $_POST['user-name'] );
122
- else $userName = '';
123
- ?>
124
- <?php echo '<input type="text" name="user-name" id="user-name" class="text-input" value="'.$userName.'" />'; ?>
125
- </p><!-- .form-username -->
126
-
127
- <p class="login-form-password">
128
- <label for="password"><?php _e('Password', 'profilebuilder'); ?></label>
129
- <input type="password" name="password" id="password" class="text-input" />
130
- </p><!-- .form-password -->
131
- <p class="login-form-submit">
132
- <input type="submit" name="submit" class="submit button" value="<?php _e('Log in', 'profilebuilder'); ?>" />
133
- <?php
134
- $loginFilterArray['rememberMe'] = '
135
- <input class="remember-me checkbox" name="remember-me" id="remember-me" type="checkbox" checked="checked" value="forever" />
136
- <label for="remember-me">'. __('Remember me', 'profilebuilder').'</label>';
137
- $loginFilterArray['rememberMe'] = apply_filters('wppb_login_remember_me', $loginFilterArray['rememberMe']);
138
- echo $loginFilterArray['rememberMe'];
139
- ?>
140
-
141
- <input type="hidden" name="action" value="log-in" />
142
- </p><!-- .form-submit -->
143
- <?php
144
- $loginFilterArray['loginURL'] = '
145
- <p>
146
- <a href="'.$siteURL=get_option('siteurl').'/wp-login.php?action=lostpassword">'. __('Lost password?', 'profilebuilder').'</a>
147
- </p>';
148
- $loginFilterArray['loginURL'] = apply_filters('wppb_login_url', $loginFilterArray['loginURL']);
149
- echo $loginFilterArray['loginURL'];
150
- ?>
151
- <?php wp_nonce_field('verify_true_login','login_nonce_field'); ?>
152
- </form><!-- .sign-in -->
153
-
154
- <?php endif;?>
155
-
156
- <?php /* use this action hook to add extra content after the login form. */ ?>
157
- <?php do_action( 'wppb_after_login' ); ?>
158
-
159
- </div>
160
- <?php
161
- $output = ob_get_contents();
162
- ob_end_clean();
163
-
164
- $loginFilterArray = apply_filters('wppb_login', $loginFilterArray);
165
-
166
- return $output;
 
 
 
 
 
167
  }
1
+ <?php
2
+ if(!function_exists('wppb_curpageurl')){
3
+ function wppb_curpageurl() {
4
+ $pageURL = 'http';
5
+ if ((isset($_SERVER["HTTPS"])) && ($_SERVER["HTTPS"] == "on")) {
6
+ $pageURL .= "s";
7
+ }
8
+ $pageURL .= "://";
9
+ if ($_SERVER["SERVER_PORT"] != "80") {
10
+ $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
11
+ } else {
12
+ $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
13
+ }
14
+ return $pageURL;
15
+ }
16
+ }
17
+
18
+ /* wp_signon can only be executed before anything is outputed in the page because of that we're adding it to the init hook */
19
+ global $wppb_login;
20
+ $wppb_login = false;
21
+
22
+ function wppb_signon(){
23
+ global $error;
24
+ global $wppb_login;
25
+
26
+ if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'log-in' && wp_verify_nonce($_POST['login_nonce_field'],'verify_true_login')){
27
+ if (isset($_POST['remember-me']))
28
+ $remember = $_POST['remember-me'];
29
+ else $remember = false;
30
+ $wppb_login = wp_signon( array( 'user_login' => $_POST['user-name'], 'user_password' => $_POST['password'], 'remember' => $_POST['remember-me'] ), false );
31
+
32
+ }elseif (isset($_GET['userName']) && isset($_GET['passWord'])){
33
+ $remember = true;
34
+ $username = $_GET['userName'];
35
+ $password = base64_decode($_GET['passWord']);
36
+ $wppb_login = wp_signon( array( 'user_login' => $username, 'user_password' => $password, 'remember' => $remember ), false );
37
+ }
38
+ }
39
+ add_action('init', 'wppb_signon');
40
+
41
+ function wppb_front_end_login(){
42
+ $loginFilterArray = array();
43
+ ob_start();
44
+ global $wppb_login;
45
+
46
+ echo '<div class="wppb_holder" id="wppb_login">';
47
+
48
+ if ( is_user_logged_in() ) : // Already logged in
49
+ global $user_ID;
50
+ $wppb_user = get_userdata( $user_ID );
51
+ if($wppb_user->display_name == ''){
52
+ $wppb_user->display_name = $wppb_user->user_login;
53
+ }
54
+
55
+ ?>
56
+ <?php
57
+ $loginFilterArray['loginMessage1'] = '
58
+ <p class="alert">'.
59
+ __('You are currently logged in as', 'profilebuilder').' <a href="'.$authorPostsUrl = get_author_posts_url( $wppb_user->ID ).'" title="'.$wppb_user->display_name.'">'.$wppb_user->display_name.'</a>.
60
+ <a href="'.wp_logout_url( get_permalink() ).'" title="'. __('Log out of this account', 'profilebuilder').'">'. __('Log out', 'profilebuilder').' &raquo;</a>
61
+ </p><!-- .alert-->';
62
+
63
+ $loginFilterArray['loginMessage1'] = apply_filters('wppb_login_login_message1', $loginFilterArray['loginMessage1']);
64
+ echo $loginFilterArray['loginMessage1'];
65
+ ?>
66
+
67
+ <?php elseif ( $wppb_login->ID ) : // Successful login ?>
68
+ <?php
69
+ if($wppb_login->display_name == ''){
70
+ $wppb_login->display_name = $wppb_login->user_login;
71
+ }
72
+
73
+ ?>
74
+
75
+ <?php
76
+ $loginFilterArray['loginMessage2'] = '
77
+ <p class="success">'.
78
+ __('You have successfully logged in as', 'profilebuilder').' <a href="'.$authorPostsUrl = get_author_posts_url( $wppb_login->ID ).'" title="'.$wppb_login->display_name.'">'.$wppb_login->display_name.'</a>.
79
+ </p><!-- .success-->';
80
+
81
+ $loginFilterArray['loginMessage2'] = apply_filters('wppb_login_login_message2', $loginFilterArray['loginMessage2']);
82
+ echo $loginFilterArray['loginMessage2'];
83
+ ?>
84
+
85
+
86
+ <?php
87
+ $permaLnk2 = get_permalink();
88
+ $wppb_addons = WPPB_PLUGIN_DIR . '/premium/addon/';
89
+ if (file_exists ( $wppb_addons.'addon.php' )){
90
+ //check to see if the redirecting addon is present and activated
91
+ $wppb_premium_addon_settings = get_option('wppb_premium_addon_settings'); //fetch the descriptions array
92
+ if ($wppb_premium_addon_settings['customRedirect'] == 'show'){
93
+ //check to see if the redirect location is not an empty string and is activated
94
+ $customRedirectSettings = get_option('customRedirectSettings');
95
+ if ((trim($customRedirectSettings['afterLoginTarget']) != '') && ($customRedirectSettings['afterLogin'] == 'yes')){
96
+ $permaLnk2 = trim($customRedirectSettings['afterLoginTarget']);
97
+ $findHttp = strpos($permaLnk2, 'http');
98
+ if ($findHttp === false)
99
+ $permaLnk2 = 'http://'. $permaLnk2;
100
+ }
101
+ }
102
+ }
103
+
104
+ $loginFilterArray['redirectMessage'] = '
105
+ <font color="black">'. __('You will soon be redirected automatically. If you see this page for more than 1 second, please click', 'profilebuilder').' <a href="'.$permaLnk2.'">'. __('here', 'profilebuilder').'</a>.<meta http-equiv="Refresh" content="1;url='.$permaLnk2.'" /></font><br/><br/>';
106
+ $loginFilterArray['redirectMessage'] = apply_filters('wppb_login_redirect_message', $loginFilterArray['redirectMessage']);
107
+ echo $loginFilterArray['redirectMessage'];
108
+ ?>
109
+ <?php else : // Not logged in ?>
110
+
111
+ <?php if (!empty( $_POST['action'] )): ?>
112
+ <p class="error">
113
+ <?php if ( trim($_POST['user-name']) == '') echo '<strong>'. __('ERROR:','profilebuilder').'</strong> '. __('The username field is empty', 'profilebuilder').'. '; ?>
114
+ <?php if ( is_wp_error($wppb_login) ) echo $wppb_login->get_error_message();?>
115
+ </p><!-- .error -->
116
+ <?php endif; ?>
117
+
118
+ <?php /* use this action hook to add extra content before the login form. */ ?>
119
+ <?php do_action( 'wppb_before_login' ); ?>
120
+
121
+ <form action="<?php wppb_curpageurl(); ?>" method="post" class="sign-in">
122
+ <p class="login-form-username">
123
+ <label for="user-name"><?php _e('Username', 'profilebuilder'); ?></label>
124
+ <?php
125
+ if (isset($_POST['user-name']))
126
+ $userName = esc_html( $_POST['user-name'] );
127
+ else $userName = '';
128
+ ?>
129
+ <?php echo '<input type="text" name="user-name" id="user-name" class="text-input" value="'.$userName.'" />'; ?>
130
+ </p><!-- .form-username -->
131
+
132
+ <p class="login-form-password">
133
+ <label for="password"><?php _e('Password', 'profilebuilder'); ?></label>
134
+ <input type="password" name="password" id="password" class="text-input" />
135
+ </p><!-- .form-password -->
136
+ <p class="login-form-submit">
137
+ <input type="submit" name="submit" class="submit button" value="<?php _e('Log in', 'profilebuilder'); ?>" />
138
+ <?php
139
+ $loginFilterArray['rememberMe'] = '
140
+ <input class="remember-me checkbox" name="remember-me" id="remember-me" type="checkbox" checked="checked" value="forever" />
141
+ <label for="remember-me">'. __('Remember me', 'profilebuilder').'</label>';
142
+ $loginFilterArray['rememberMe'] = apply_filters('wppb_login_remember_me', $loginFilterArray['rememberMe']);
143
+ echo $loginFilterArray['rememberMe'];
144
+ ?>
145
+
146
+ <input type="hidden" name="action" value="log-in" />
147
+ </p><!-- .form-submit -->
148
+ <?php
149
+ $loginFilterArray['loginURL'] = '
150
+ <p>
151
+ <a href="'.$siteURL=get_option('siteurl').'/wp-login.php?action=lostpassword">'. __('Lost password?', 'profilebuilder').'</a>
152
+ </p>';
153
+ $loginFilterArray['loginURL'] = apply_filters('wppb_login_url', $loginFilterArray['loginURL']);
154
+ echo $loginFilterArray['loginURL'];
155
+ ?>
156
+ <?php wp_nonce_field('verify_true_login','login_nonce_field'); ?>
157
+ </form><!-- .sign-in -->
158
+
159
+ <?php endif;?>
160
+
161
+ <?php /* use this action hook to add extra content after the login form. */ ?>
162
+ <?php do_action( 'wppb_after_login' ); ?>
163
+
164
+ </div>
165
+ <?php
166
+ $output = ob_get_contents();
167
+ ob_end_clean();
168
+
169
+ $loginFilterArray = apply_filters('wppb_login', $loginFilterArray);
170
+
171
+ return $output;
172
  }
front-end/wppb.register.php CHANGED
@@ -1,935 +1,990 @@
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 if the version number is less then 3.1. */
29
- $versionNo = get_bloginfo( 'version' );
30
- if ($versionNo <= '3.1')
31
- require_once(ABSPATH . WPINC . '/registration.php');
32
-
33
- /* Check if users can register. */
34
- $registration = get_option( 'users_can_register' );
35
-
36
-
37
- //fallback if the file was largen then post_max_size, case in which no errors can be saved in $_FILES[fileName]['error']
38
- if (empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
39
- $registerFilterArray['noPostError'] = '
40
- <p class="error">'.
41
- __('The information size you were trying to submit was larger than', 'profilebuilder') .' '. ServerMaxUploadSizeMega .'b!<br/>'.
42
- __('This is usually caused by a large file(s) trying to be uploaded.', 'profilebuilder') .'<br/>'.
43
- __('Since it was also larger than', 'profilebuilder') .' '. ServerMaxPostSizeMega .'b, '. __('no additional information is available.', 'profilebuilder'). '<br/>'.
44
- __('The user was NOT created!', 'profilebuilder') .
45
- '</p>';
46
- $registerFilterArray['noPostError'] = apply_filters('wppb_register_no_post_error_message', $registerFilterArray['noPostError']);
47
- echo $registerFilterArray['noPostError'];
48
- }
49
-
50
- /* If user registered, input info. */
51
- if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'adduser' && wp_verify_nonce($_POST['register_nonce_field'],'verify_true_registration') ) {
52
- //global $wp_roles;
53
-
54
- //get value sent in the shortcode as parameter, default to "subscriber" if not set
55
- extract(shortcode_atts(array('role' => 'subscriber'), $atts));
56
-
57
- //check if the specified role exists in the database, else fall back to the "safe-zone"
58
- $found = get_role($role);
59
-
60
- if ($found != null)
61
- $aprovedRole = $role;
62
- else $aprovedRole = get_option( 'default_role' );
63
-
64
- /* preset the values in case some are not submitted */
65
- $user_pass = '';
66
- if (isset($_POST['passw1']))
67
- $user_pass = esc_attr( $_POST['passw1'] );
68
- $user_name = '';
69
- if (isset($_POST['user_name']))
70
- $user_name = trim ($_POST['user_name']);
71
- $first_name = '';
72
- if (isset($_POST['first_name']))
73
- $first_name = trim ($_POST['first_name']);
74
- $last_name = '';
75
- if (isset($_POST['last_name']))
76
- $last_name = trim ($_POST['last_name']);
77
- $nickname = '';
78
- if (isset($_POST['nickname']))
79
- $nickname = trim ($_POST['nickname']);
80
- $email = '';
81
- if (isset($_POST['email']))
82
- $email = trim ($_POST['email']);
83
- $website = '';
84
- if (isset($_POST['website']))
85
- $website = trim ($_POST['website']);
86
- $aim = '';
87
- if (isset($_POST['aim']))
88
- $aim = trim ($_POST['aim']);
89
- $yim = '';
90
- if (isset($_POST['yim']))
91
- $yim = trim ($_POST['yim']);
92
- $jabber = '';
93
- if (isset($_POST['jabber']))
94
- $jabber = trim ($_POST['jabber']);
95
- $description = '';
96
- if (isset($_POST['description']))
97
- $description = trim ($_POST['description']);
98
-
99
- /* use filters to modify (if needed) the posted data before creating the user-data */
100
- $user_pass = apply_filters('wppb_register_posted_password', $user_pass);
101
- $user_name = apply_filters('wppb_register_posted_email', $user_name);
102
- $first_name = apply_filters('wppb_register_posted_first_name', $first_name);
103
- $last_name = apply_filters('wppb_register_posted_last_name', $last_name);
104
- $nickname = apply_filters('wppb_register_posted_nickname', $nickname);
105
- $email = apply_filters('wppb_register_posted_email', $email);
106
- $website = apply_filters('wppb_register_posted_website', $website);
107
- $aim = apply_filters('wppb_register_posted_aim', $aim);
108
- $yim = apply_filters('wppb_register_posted_yahoo', $yim);
109
- $jabber = apply_filters('wppb_register_posted_jabber', $jabber);
110
- $description = apply_filters('wppb_register_posted_bio', $description);
111
- /* END use filters to modify (if needed) the posted data before creating the user-data */
112
-
113
- $userdata = array(
114
- 'user_pass' => $user_pass,
115
- 'user_login' => esc_attr( $user_name ),
116
- 'first_name' => esc_attr( $first_name ),
117
- 'last_name' => esc_attr( $last_name ),
118
- 'nickname' => esc_attr( $nickname ),
119
- 'user_email' => esc_attr( $email ),
120
- 'user_url' => esc_attr( $website ),
121
- 'aim' => esc_attr( $aim ),
122
- 'yim' => esc_attr( $yim ),
123
- 'jabber' => esc_attr( $jabber ),
124
- 'description' => esc_attr( $description ),
125
- 'role' => $aprovedRole);
126
-
127
- //get required and shown fields
128
- $wppb_defaultOptions = get_option('wppb_default_settings');
129
-
130
- //check if the user agreed to the terms and conditions (if it was set)
131
- $wppb_premium = wppb_plugin_dir . '/premium/functions/';
132
- if (file_exists ( $wppb_premium.'extra.fields.php' )){
133
- $wppbFetchArray = get_option('wppb_custom_fields');
134
- foreach ( $wppbFetchArray as $key => $value){
135
- switch ($value['item_type']) {
136
- case "agreeToTerms":{
137
- $agreed = false;
138
- if ( (isset($_POST[$value['item_id'].$value['id']] )) && ($_POST[$value['item_id'].$value['id']] == 'agree'))
139
- $agreed = true;
140
- break;
141
- }
142
- }
143
- }
144
- }
145
-
146
- $registerFilterArray['extraError'] = ''; //this is for creating extra error message and bypassing registration
147
- $registerFilterArray['extraError'] = apply_filters('wppb_register_extra_error', $registerFilterArray['extraError']);
148
-
149
- /* check if all the required fields were completed */
150
- if($wppb_defaultOptions['firstname'] == 'show'){
151
- if (($wppb_defaultOptions['firstnameRequired'] == 'yes') && (trim($_POST['first_name']) == ''))
152
- $firstnameComplete = 'no';
153
- }elseif($wppb_defaultOptions['lastname'] == 'show'){
154
- if (($wppb_defaultOptions['lastnameRequired'] == 'yes') && (trim($_POST['last_name']) == ''))
155
- $lastnameComplete = 'no';
156
- }elseif($wppb_defaultOptions['nickname'] == 'show'){
157
- if (($wppb_defaultOptions['nicknameRequired'] == 'yes') && (trim($_POST['nickname']) == ''))
158
- $nicknameComplete = 'no';
159
- }elseif($wppb_defaultOptions['website'] == 'show'){
160
- if (($wppb_defaultOptions['websiteRequired'] == 'yes') && (trim($_POST['website']) == ''))
161
- $websiteComplete = 'no';
162
- }elseif($wppb_defaultOptions['aim'] == 'show'){
163
- if (($wppb_defaultOptions['aimRequired'] == 'yes') && (trim($_POST['aim']) == ''))
164
- $aimComplete = 'no';
165
- }elseif($wppb_defaultOptions['yahoo'] == 'show'){
166
- if (($wppb_defaultOptions['yahooRequired'] == 'yes') && (trim($_POST['yahoo']) == ''))
167
- $yahooComplete = 'no';
168
- }elseif($wppb_defaultOptions['jabber'] == 'show'){
169
- if (($wppb_defaultOptions['jabberRequired'] == 'yes') && (trim($_POST['jabber']) == ''))
170
- $jabberComplete = 'no';
171
- }elseif($wppb_defaultOptions['bio'] == 'show'){
172
- if (($wppb_defaultOptions['bioRequired'] == 'yes') && (trim($_POST['description']) == ''))
173
- $bioComplete = 'no';
174
- }
175
-
176
- // check the extra fields also
177
- $wppb_premium = wppb_plugin_dir . '/premium/functions/';
178
- if (file_exists ( $wppb_premium.'extra.fields.php' )){
179
- $wppbFetchArray = get_option('wppb_custom_fields');
180
- foreach ( $wppbFetchArray as $key => $value){
181
- switch ($value['item_type']) {
182
- case "input":{
183
- $_POST[$value['item_id'].$value['id']] = apply_filters('wppb_register_input_custom_field_'.$value['id'], $_POST[$value['item_id'].$value['id']]);
184
- if (isset($value['item_required'])){
185
- if ($value['item_required'] == 'yes'){
186
- if (trim($_POST[$value['item_id'].$value['id']]) == '')
187
- array_push($extraFieldsErrorHolder, $value['id']);
188
- }
189
- }
190
- break;
191
- }
192
- case "checkbox":{
193
- $checkboxOption = '';
194
- $checkboxValue = explode(',', $value['item_options']);
195
- foreach($checkboxValue as $thisValue){
196
- $thisValue = str_replace(' ', '#@space@#', $thisValue); //we need to escape the space-codification we sent earlier in the post
197
- if (isset($_POST[$thisValue.$value['id']])){
198
- $localValue = str_replace('#@space@#', ' ', $_POST[$thisValue.$value['id']]);
199
- $checkboxOption = $checkboxOption.$localValue.',';
200
- }
201
- }
202
-
203
- if (isset($value['item_required'])){
204
- if ($value['item_required'] == 'yes'){
205
- if (trim($checkboxOption) == '')
206
- array_push($extraFieldsErrorHolder, $value['id']);
207
- }
208
- }
209
- break;
210
- }
211
- case "radio":{
212
- if (isset($value['item_required'])){
213
- if ($value['item_required'] == 'yes'){
214
- if (trim($_POST[$value['item_id'].$value['id']]) == '')
215
- array_push($extraFieldsErrorHolder, $value['id']);
216
- }
217
- }
218
- break;
219
- }
220
- case "select":{
221
- if (isset($value['item_required'])){
222
- if ($value['item_required'] == 'yes'){
223
- if (trim($_POST[$value['item_id'].$value['id']]) == '')
224
- array_push($extraFieldsErrorHolder, $value['id']);
225
- }
226
- }
227
- break;
228
- }
229
- case "countrySelect":{
230
- if (isset($value['item_required'])){
231
- if ($value['item_required'] == 'yes'){
232
- if (trim($_POST[$value['item_id'].$value['id']]) == '')
233
- array_push($extraFieldsErrorHolder, $value['id']);
234
- }
235
- }
236
- break;
237
- }
238
- case "timeZone":{
239
- if (isset($value['item_required'])){
240
- if ($value['item_required'] == 'yes'){
241
- if (trim($_POST[$value['item_id'].$value['id']]) == '')
242
- array_push($extraFieldsErrorHolder, $value['id']);
243
- }
244
- }
245
- break;
246
- }
247
- case "datepicker":{
248
- if (isset($value['item_required'])){
249
- if ($value['item_required'] == 'yes'){
250
- if (trim($_POST[$value['item_id'].$value['id']]) == '')
251
- array_push($extraFieldsErrorHolder, $value['id']);
252
- }
253
- }
254
- break;
255
- }
256
- case "textarea":{
257
- if (isset($value['item_required'])){
258
- if ($value['item_required'] == 'yes'){
259
- if (trim($_POST[$value['item_id'].$value['id']]) == '')
260
- array_push($extraFieldsErrorHolder, $value['id']);
261
- }
262
- }
263
- break;
264
- }
265
- case "upload":{
266
- $uploadedfile = $value['item_type'].$value['id'];
267
- if ( (basename( $_FILES[$uploadedfile]['name']) == '')){
268
- if (isset($value['item_required'])){
269
- if ($value['item_required'] == 'yes')
270
- array_push($extraFieldsErrorHolder, $value['id']);
271
- }
272
- }
273
- break;
274
- }
275
- case "avatar":{
276
-
277
- $uploadedfile = $value['item_type'].$value['id'];
278
-
279
- if ( (basename( $_FILES[$uploadedfile]['name']) == '')){
280
- 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'))
281
- if (isset($value['item_required'])){
282
- if ($value['item_required'] == 'yes')
283
- array_push($extraFieldsErrorHolder, $value['id']);
284
- }
285
- }
286
- break;
287
- }
288
- }
289
- }
290
- }
291
-
292
- /* END check if all the required fields were completed */
293
-
294
- if ($registerFilterArray['extraError'] != '')
295
- $error = $registerFilterArray['extraError'];
296
- elseif ( !$userdata['user_login'] )
297
- $error = __('A username is required for registration.', 'profilebuilder');
298
- elseif ( username_exists($userdata['user_login']) )
299
- $error = __('Sorry, that username already exists!', 'profilebuilder');
300
- elseif ( !is_email($userdata['user_email'], true) )
301
- $error = __('You must enter a valid email address.', 'profilebuilder');
302
- elseif ( email_exists($userdata['user_email']) )
303
- $error = __('Sorry, that email address is already used!', 'profilebuilder');
304
- elseif (( empty($_POST['passw1'] ) || empty( $_POST['passw2'] )) || ( $_POST['passw1'] != $_POST['passw2'] )){
305
- if ( empty($_POST['passw1'] ) || empty( $_POST['passw2'] )) //verify if the user has completed both password fields
306
- $error = __('You didn\'t complete one of the password-fields!', 'profilebuilder');
307
- elseif ( $_POST['passw1'] != $_POST['passw2'] ) //verify if the the password and the retyped password are a match
308
- $error = __('The entered passwords don\'t match!', 'profilebuilder');
309
- }
310
- elseif ( $agreed == false )
311
- $error = __('You must agree to the terms and conditions before registering!', 'profilebuilder');
312
- elseif(($firstnameComplete == 'no' || $lastnameComplete == 'no' || $nicknameComplete == 'no' || $websiteComplete == 'no' || $aimComplete == 'no' || $yahooComplete == 'no' || $jabberComplete == 'no' || $bioComplete == 'no' ) || !empty($extraFieldsErrorHolder))
313
- $error = __('The account was NOT created!', 'profilebuilder') .'<br/>'. __('(Several required fields were left uncompleted)', 'profilebuilder');
314
- else{
315
- $registered_name = $_POST['user_name'];
316
- $new_user = wp_insert_user( $userdata );
317
-
318
- /* add the extra profile information */
319
- $wppb_premium = wppb_plugin_dir . '/premium/functions/';
320
- if (file_exists ( $wppb_premium.'extra.fields.php' )){
321
- $wppbFetchArray = get_option('wppb_custom_fields');
322
- foreach ( $wppbFetchArray as $key => $value){
323
- switch ($value['item_type']) {
324
- case "input":{
325
- add_user_meta( $new_user, 'custom_field_'.$value['id'], esc_attr($_POST[$value['item_id'].$value['id']]) );
326
- break;
327
- }
328
- case "hiddenInput":{
329
- add_user_meta( $new_user, 'custom_field_'.$value['id'], esc_attr($_POST[$value['item_id'].$value['id']]) );
330
- break;
331
- }
332
- case "checkbox":{
333
- $checkboxOption = '';
334
- $checkboxValue = explode(',', $value['item_options']);
335
- foreach($checkboxValue as $thisValue){
336
- $thisValue = str_replace(' ', '#@space@#', $thisValue); //we need to escape the space-codification we sent earlier in the post
337
- if (isset($_POST[$thisValue.$value['id']])){
338
- $localValue = str_replace('#@space@#', ' ', $_POST[$thisValue.$value['id']]);
339
- $checkboxOption = $checkboxOption.$localValue.',';
340
- }
341
- }
342
-
343
- add_user_meta( $new_user, 'custom_field_'.$value['id'], $checkboxOption );
344
- break;
345
- }
346
- case "radio":{
347
- add_user_meta( $new_user, 'custom_field_'.$value['id'], $_POST[$value['item_id'].$value['id']] );
348
- break;
349
- }
350
- case "select":{
351
- add_user_meta( $new_user, 'custom_field_'.$value['id'], $_POST[$value['item_id'].$value['id']] );
352
- break;
353
- }
354
- case "countrySelect":{
355
- update_user_meta( $new_user, 'custom_field_'.$value['id'], $_POST[$value['item_id'].$value['id']] );
356
- break;
357
- }
358
- case "timeZone":{
359
- update_user_meta( $new_user, 'custom_field_'.$value['id'], $_POST[$value['item_id'].$value['id']] );
360
- break;
361
- }
362
- case "datepicker":{
363
- update_user_meta( $new_user, 'custom_field_'.$value['id'], $_POST[$value['item_id'].$value['id']] );
364
- break;
365
- }
366
- case "textarea":{
367
- add_user_meta( $new_user, 'custom_field_'.$value['id'], esc_attr($_POST[$value['item_id'].$value['id']]) );
368
- break;
369
- }
370
- case "upload":{
371
-
372
- $uploadedfile = $value['item_type'].$value['id'];
373
-
374
- //first we need to verify if we don't try to upload a 0b or 0 length file
375
- if ( (basename( $_FILES[$uploadedfile]['name']) != '')){
376
-
377
- //second we need to verify if the uploaded file size is less then the set file size in php.ini
378
- if (($_FILES[$uploadedfile]['size'] < ServerMaxUploadSizeByte) && ($_FILES[$uploadedfile]['size'] !=0)){
379
- //we need to prepare the basename of the file, so that ' becomes ` as ' gives an error
380
- $fileName = basename( $_FILES[$uploadedfile]['name']);
381
- $finalFileName = '';
382
-
383
- for ($i=0; $i < strlen($fileName); $i++){
384
- if ($fileName[$i] == "'")
385
- $finalFileName .= '`';
386
- else $finalFileName .= $fileName[$i];
387
- }
388
-
389
- //create the target path for uploading
390
- $wpUploadPath = wp_upload_dir(); // Array of key => value pairs
391
- $target_path = $wpUploadPath['basedir']."/profile_builder/attachments/";
392
- $target_path = $target_path . 'userID_'.$new_user.'_attachment_'. $finalFileName;
393
-
394
- if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)){
395
- //$upFile = get_bloginfo('home').'/'.$target_path;
396
- $upFile = $wpUploadPath['baseurl'].'/profile_builder/attachments/userID_'.$new_user.'_attachment_'. $finalFileName;
397
- add_user_meta( $new_user, 'custom_field_'.$value['id'], $upFile );
398
- $pictureUpload = 'yes';
399
- }
400
- }
401
- }
402
- break;
403
- }
404
- case "avatar":{
405
-
406
- $uploadedfile = $value['item_type'].$value['id'];
407
- $wpUploadPath = wp_upload_dir(); // Array of key => value pairs
408
- $target_path_original = $wpUploadPath['basedir']."/profile_builder/avatars/";
409
- $fileName = $_FILES[$uploadedfile]['name'];
410
- $finalFileName = '';
411
-
412
- for ($i=0; $i < strlen($fileName); $i++){
413
- if ($fileName[$i] == "'")
414
- $finalFileName .= '`';
415
- elseif ($fileName[$i] == ' ')
416
- $finalFileName .= '_';
417
- else $finalFileName .= $fileName[$i];
418
- }
419
-
420
- $fileName = $finalFileName;
421
-
422
- $target_path = $target_path_original . 'userID_'.$new_user.'_originalAvatar_'. $fileName;
423
-
424
- /* when trying to upload file, be sure it's one of the accepted image file-types */
425
- 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)) ){
426
- $wp_filetype = wp_check_filetype(basename( $_FILES[$uploadedfile]['name']), null );
427
- $attachment = array('post_mime_type' => $wp_filetype['type'],
428
- 'post_title' => $fileName, //preg_replace('/\.[^.]+$/', '', basename($_FILES[$uploadedfile]['name'])),
429
- 'post_content' => '',
430
- 'post_status' => 'inherit'
431
- );
432
-
433
-
434
- $attach_id = wp_insert_attachment( $attachment, $target_path);
435
-
436
- $upFile = image_downsize( $attach_id, 'thumbnail' );
437
- $upFile = $upFile[0];
438
-
439
- //if file upload succeded
440
- if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)){
441
- add_user_meta( $new_user, 'custom_field_'.$value['id'], $upFile );
442
- $avatarUpload = 'yes';
443
- }
444
- else $avatarUpload = 'no';
445
- }
446
- if (($_FILES[$uploadedfile]['type'] == ''))
447
- $avatarUpload = 'yes';
448
-
449
- break;
450
- }
451
- }
452
- }
453
- }
454
-
455
-
456
- //send an email to the admin regarding each and every new subscriber
457
- $bloginfo = get_bloginfo( 'name' );
458
- $registerFilterArray['adminMessageOnRegistration'] = '';
459
- $registerFilterArray['adminMessageOnRegistration'] = __('New subscriber on', 'profilebuilder') .' '.$bloginfo . "\r\n\r\n";
460
- $registerFilterArray['adminMessageOnRegistration'] .= __('Username', 'profilebuilder') .': '. esc_attr($_POST['user_name']) . "\r\n";
461
- $registerFilterArray['adminMessageOnRegistration'] .= __('E-mail', 'profilebuilder') .': '. esc_attr($_POST['email']) . "\r\n";
462
- $registerFilterArray['adminMessageOnRegistration'] = apply_filters('wppb_register_admin_message_content', $registerFilterArray['adminMessageOnRegistration']);
463
-
464
- $registerFilterArray['adminMessageOnRegistrationTitle'] = '['. $bloginfo .']'. __('A new subscriber has (been) registered!');
465
- $registerFilterArray['adminMessageOnRegistrationTitle'] = apply_filters ('wppb_register_admin_message_title', $registerFilterArray['adminMessageOnRegistrationTitle']);
466
-
467
- if (trim($registerFilterArray['adminMessageOnRegistration']) != '')
468
- wp_mail(get_option('admin_email'), $registerFilterArray['adminMessageOnRegistrationTitle'], $registerFilterArray['adminMessageOnRegistration']);
469
-
470
-
471
- //send an email to the newly registered user, if this option was selected
472
- if (isset($_POST['send_credentials_via_email']) && ($_POST['send_credentials_via_email'] == 'sending')){
473
- //change these variables to modify sent email message, destination and source.
474
- $email = $_POST['email'];
475
- $mailPassword = $_POST['passw1'];
476
- $mailUsername = $_POST['user_name'];
477
-
478
- $registerFilterArray['userMessageFrom'] = get_bloginfo('name');
479
- $registerFilterArray['userMessageFrom'] = apply_filters('wppb_register_from_email_content', $registerFilterArray['userMessageFrom']);
480
-
481
- $registerFilterArray['userMessageSubject'] = 'A new account has been created for you.';
482
- $registerFilterArray['userMessageSubject'] = apply_filters('wppb_register_subject_email_content', $registerFilterArray['userMessageSubject']);
483
-
484
- $registerFilterArray['userMessageContent'] = 'Welcome to blog '.$registerFilterArray['userMessageFrom'].'. Your username is:'.$mailUsername.' and password:'.$mailPassword;
485
- $registerFilterArray['userMessageContent'] = apply_filters('wppb_register_email_content', $registerFilterArray['userMessageContent']);
486
-
487
- $messageSent = wp_mail( $email, $registerFilterArray['userMessageSubject'], $registerFilterArray['userMessageContent']);
488
- if( $messageSent == TRUE)
489
- $sentEmailStatus = 2;
490
- else
491
- $sentEmailStatus = 1;
492
- }
493
-
494
- }
495
- }
496
-
497
- ?>
498
- <div class="wppb_holder" id="wppb_register">
499
- <?php
500
- if ( is_user_logged_in() && !current_user_can( 'create_users' ) ) :
501
-
502
- global $user_ID;
503
- $login = get_userdata( $user_ID );
504
- if($login->display_name == ''){
505
- $login->display_name = $login->user_login;
506
- }
507
- $registerFilterArray['loginLogoutError'] = '
508
- <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 -->';
509
- $registerFilterArray['loginLogoutError'] = apply_filters('wppb_register_have_account_alert', $registerFilterArray['loginLogoutError']);
510
- echo $registerFilterArray['loginLogoutError'];
511
-
512
- elseif ( $new_user != 'no' ) :
513
- if ( current_user_can( 'create_users' ) ){
514
- $registerFilterArray['registrationMessage1'] = '
515
- <p class="success">'. __('A user account has been created for', 'profilebuilder') .' '. $registered_name. '.</p><!-- .success -->';
516
- $registerFilterArray['registrationMessage1'] = apply_filters('wppb_register_account_created1', $registerFilterArray['registrationMessage1']);
517
- echo $registerFilterArray['registrationMessage1'];
518
-
519
- $wppb_addons = wppb_plugin_dir . '/premium/addon/';
520
- if (file_exists ( $wppb_addons.'addon.php' )){
521
- //check to see if the redirecting addon is present and activated
522
- $wppb_premium_addon_settings = get_option('wppb_premium_addon_settings');
523
- if ($wppb_premium_addon_settings['customRedirect'] == 'show'){
524
- //check to see if the redirect location is not an empty string and is activated
525
- $customRedirectSettings = get_option('customRedirectSettings');
526
- if ((trim($customRedirectSettings['afterRegisterTarget']) != '') && ($customRedirectSettings['afterRegister'] == 'yes')){
527
- $redirectLink = trim($customRedirectSettings['afterRegisterTarget']);
528
- $findHttp = strpos($redirectLink, 'http');
529
- if ($findHttp === false)
530
- $redirectLink = 'http://'. $redirectLink;
531
- }
532
- }
533
- }
534
- $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/>';
535
- $registerFilterArray['redirectMessage1'] = apply_filters('wppb_register_redirect_after_creation1', $registerFilterArray['redirectMessage1']);
536
- echo $registerFilterArray['redirectMessage1'];
537
-
538
- }else{
539
- $registerFilterArray['registrationMessage2'] = '
540
- <p class="success">'. __('Thank you for registering', 'profilebuilder') .' '. $registered_name .'.</p><!-- .success -->';
541
- $registerFilterArray['registrationMessage2'] = apply_filters('wppb_register_account_created2', $registerFilterArray['registrationMessage2']);
542
- echo $registerFilterArray['registrationMessage2'];
543
-
544
- $wppb_addons = wppb_plugin_dir . '/premium/addon/';
545
- if (file_exists ( $wppb_addons.'addon.php' )){
546
- //check to see if the redirecting addon is present and activated
547
- $wppb_premium_addon_settings = get_option('wppb_premium_addon_settings');
548
- if ($wppb_premium_addon_settings['customRedirect'] == 'show'){
549
- //check to see if the redirect location is not an empty string and is activated
550
- $customRedirectSettings = get_option('customRedirectSettings');
551
- if ((trim($customRedirectSettings['afterRegisterTarget']) != '') && ($customRedirectSettings['afterRegister'] == 'yes')){
552
- $redirectLink = trim($customRedirectSettings['afterRegisterTarget']);
553
- $findHttp = strpos($redirectLink, 'http');
554
- if ($findHttp === false)
555
- $redirectLink = 'http://'. $redirectLink;
556
- }
557
- }
558
- }
559
- $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/>';
560
- $registerFilterArray['redirectMessage2'] = apply_filters('wppb_register_redirect_after_creation2', $registerFilterArray['redirectMessage2']);
561
- echo $registerFilterArray['redirectMessage2'];
562
- }
563
-
564
-
565
- if(isset($_POST['send_credentials_via_email'])){
566
- if ($sentEmailStatus == 1){
567
- $registerFilterArray['emailMessage1'] = '<p class="error">'. __('An error occured while trying to send the notification email.', 'profilebuilder') .'</p><!-- .error -->';
568
- $registerFilterArray['emailMessage1'] = apply_filters('wppb_register_send_notification_email_fail', $registerFilterArray['emailMessage1']);
569
- echo $registerFilterArray['emailMessage1'];
570
- }elseif ($sentEmailStatus == 2){
571
- $registerFilterArray['emailMessage2'] = '<p class="success">'. __('An email containing the username and password was successfully sent.', 'profilebuilder') .'</p><!-- .success -->';
572
- $registerFilterArray['emailMessage2'] = apply_filters('wppb_register_send_notification_email_success', $registerFilterArray['emailMessage2']);
573
- echo $registerFilterArray['emailMessage2'];
574
- }
575
- }
576
- ?>
577
- <?php
578
- else :
579
- if ( $error ) :
580
- $registerFilterArray['errorMessage'] = '<p class="error">'. $error .'</p><!-- .error -->';
581
- $registerFilterArray['errorMessage'] = apply_filters('wppb_register_error_messaging', $registerFilterArray['errorMessage']);
582
- echo $registerFilterArray['errorMessage'];
583
- endif;
584
-
585
- if ( current_user_can( 'create_users' ) && $registration ) :
586
- $registerFilterArray['alertMessage1'] = '<p class="alert">'. __('Users can register themselves or you can manually create users here.', 'profilebuilder') .'</p><!-- .alert -->';
587
- $registerFilterArray['alertMessage1'] = apply_filters('wppb_register_alert_messaging1', $registerFilterArray['alertMessage1']);
588
- echo $registerFilterArray['alertMessage1'];
589
-
590
- elseif ( current_user_can( 'create_users' ) ) :
591
- $registerFilterArray['alertMessage2'] = '<p class="alert">'. __('Users cannot currently register themselves, but you can manually create users here.', 'profilebuilder') .'</p><!-- .alert -->';
592
- $registerFilterArray['alertMessage2'] = apply_filters('wppb_register_alert_messaging2', $registerFilterArray['alertMessage2']);
593
- echo $registerFilterArray['alertMessage2'];
594
-
595
- elseif ( !current_user_can( 'create_users' ) && !$registration) :
596
- $registerFilterArray['alertMessage3'] = '<p class="alert">'. __('Only an administrator can add new users.', 'profilebuilder') .'</p><!-- .alert -->';
597
- $registerFilterArray['alertMessage3'] = apply_filters('wppb_register_alert_messaging3', $registerFilterArray['alertMessage3']);
598
- echo $registerFilterArray['alertMessage3'];
599
- endif;
600
-
601
- if ( $registration || current_user_can( 'create_users' ) ) :
602
- /* use this action hook to add extra content before the register form. */
603
- do_action( 'wppb_before_register_fields' );
604
- ?>
605
- <form enctype="multipart/form-data" method="post" id="adduser" class="user-forms" action="http://<?php echo $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>">
606
- <?php
607
- 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 -->';
608
-
609
- $registerFilterArray['name1'] = '<p class="registerNameHeading"><strong>'. __('Name', 'profilebuilder') .'</strong></p>';
610
- $registerFilterArray['name1'] = apply_filters('wppb_register_content_name1', $registerFilterArray['name1']);
611
- echo $registerFilterArray['name1'];
612
-
613
- if ($wppb_defaultOptions['username'] == 'show'){
614
- $errorMark = '';
615
- if ($wppb_defaultOptions['usernameRequired'] == 'yes'){
616
- $errorMark = '<font color="red" title="This field is required for registration.">*</font>';
617
- }
618
-
619
- $localVar = '';
620
- if (isset($_POST['user_name']))
621
- $localVar = $_POST['user_name'];
622
- $registerFilterArray['name2'] = '
623
- <p class="form-username">
624
- <label for="user_name">'. __('Username', 'profilebuilder') .$errorMark.'</label>
625
- <input class="text-input" name="user_name" type="text" id="user_name" value="'.trim($localVar).'" />
626
- <span class="wppb-description-delimiter">'. __('(required)', 'profilebuilder') .'</span>
627
- </p><!-- .form-username -->';
628
- $registerFilterArray['name2'] = apply_filters('wppb_register_content_name2', $registerFilterArray['name2']);
629
- echo $registerFilterArray['name2'];
630
- }
631
-
632
- if ($wppb_defaultOptions['firstname'] == 'show'){
633
- $errorVar = '';
634
- $errorMark = '';
635
- if ($wppb_defaultOptions['firstnameRequired'] == 'yes'){
636
- $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
637
- if (isset($_POST['first_name'])){
638
- if (trim($_POST['first_name']) == ''){
639
- $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)."/>';
640
- $errorVar = ' errorHolder';
641
- }
642
- }
643
- }
644
-
645
- $localVar = '';
646
- if (isset($_POST['first_name']))
647
- $localVar = $_POST['first_name'];
648
- $registerFilterArray['name3'] = '
649
- <p class="first_name'.$errorVar.'">
650
- <label for="first_name">'. __('First Name', 'profilebuilder') .$errorMark.'</label>
651
- <input class="text-input" name="first_name" type="text" id="first_name" value="'.trim($localVar).'" />
652
- </p><!-- .first_name -->';
653
- $registerFilterArray['name3'] = apply_filters('wppb_register_content_name3', $registerFilterArray['name3']);
654
- echo $registerFilterArray['name3'];
655
- }
656
-
657
- if ($wppb_defaultOptions['lastname'] == 'show'){
658
- $errorVar = '';
659
- $errorMark = '';
660
- if ($wppb_defaultOptions['lastnameRequired'] == 'yes'){
661
- $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
662
- if (isset($_POST['last_name'])){
663
- if (trim($_POST['last_name']) == ''){
664
- $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)."/>';
665
- $errorVar = ' errorHolder';
666
- }
667
- }
668
- }
669
-
670
- $localVar = '';
671
- if (isset($_POST['last_name']))
672
- $localVar = $_POST['last_name'];
673
- $registerFilterArray['name4'] = '
674
- <p class="last_name'.$errorVar.'">
675
- <label for="last_name">'. __('Last Name', 'profilebuilder') .$errorMark.'</label>
676
- <input class="text-input" name="last_name" type="text" id="last_name" value="'.trim($localVar).'" />
677
- </p><!-- .last_name -->';
678
- $registerFilterArray['name4'] = apply_filters('wppb_register_content_name4', $registerFilterArray['name4']);
679
- echo $registerFilterArray['name4'];
680
- }
681
-
682
- if ($wppb_defaultOptions['nickname'] == 'show'){
683
- $errorVar = '';
684
- $errorMark = '';
685
- if ($wppb_defaultOptions['nicknameRequired'] == 'yes'){
686
- $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
687
- if (isset($_POST['nickname'])){
688
- if (trim($_POST['nickname']) == ''){
689
- $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)."/>';
690
- $errorVar = ' errorHolder';
691
- }
692
- }
693
- }
694
-
695
- $localVar = '';
696
- if (isset($_POST['nickname']))
697
- $localVar = $_POST['nickname'];
698
- $registerFilterArray['name5'] = '
699
- <p class="nickname'.$errorVar.'">
700
- <label for="nickname">'. __('Nickname', 'profilebuilder') .$errorMark.'</label>
701
- <input class="text-input" name="nickname" type="text" id="nickname" value="'.trim($localVar).'" />
702
- </p><!-- .nickname -->';
703
- $registerFilterArray['name5'] = apply_filters('wppb_register_content_name5', $registerFilterArray['name5']);
704
- echo $registerFilterArray['name5'];
705
- }
706
-
707
- $registerFilterArray['info1'] = '<p class="registerContactInfoHeading"><strong>'. __('Contact Info', 'profilebuilder') .'</strong></p>';
708
- $registerFilterArray['info1'] = apply_filters('wppb_register_content_info1', $registerFilterArray['info1']);
709
- echo $registerFilterArray['info1'];
710
-
711
- if ($wppb_defaultOptions['email'] == 'show'){
712
- $errorVar = '';
713
- $errorMark = '';
714
- if ($wppb_defaultOptions['emailRequired'] == 'yes'){
715
- $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
716
- if (isset($_POST['email']))
717
- if (trim($_POST['email']) == '')
718
- $errorMark = '<img src="'.wppb_plugin_url . '/assets/images/pencil_delete.png" title="This field is required for registration."/>';
719
- }
720
-
721
- $localVar = '';
722
- if (isset($_POST['email']))
723
- $localVar = $_POST['email'];
724
- $registerFilterArray['info2'] = '
725
- <p class="form-email">
726
- <label for="email">'. __('E-mail', 'profilebuilder') .$errorMark.'</label>
727
- <input class="text-input" name="email" type="text" id="email" value="'.trim($localVar).'" />
728
- <span class="wppb-description-delimiter">'. __('(required)', 'profilebuilder') .'</span>
729
- </p><!-- .form-email -->';
730
- $registerFilterArray['info2'] = apply_filters('wppb_register_content_info2', $registerFilterArray['info2']);
731
- echo $registerFilterArray['info2'];
732
- }
733
-
734
- if ($wppb_defaultOptions['website'] == 'show'){
735
- $errorVar = '';
736
- $errorMark = '';
737
- if ($wppb_defaultOptions['websiteRequired'] == 'yes'){
738
- $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
739
- if (isset($_POST['website'])){
740
- if (trim($_POST['website']) == ''){
741
- $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)."/>';
742
- $errorVar = ' errorHolder';
743
- }
744
- }
745
- }
746
-
747
- $localVar = '';
748
- if (isset($_POST['website']))
749
- $localVar = $_POST['website'];
750
- $registerFilterArray['info3'] = '
751
- <p class="form-website'.$errorVar.'">
752
- <label for="website">'. __('Website', 'profilebuilder') .$errorMark.'</label>
753
- <input class="text-input" name="website" type="text" id="website" value="'.trim($localVar).'" />
754
- </p><!-- .form-website -->';
755
- $registerFilterArray['info3'] = apply_filters('wppb_register_content_info3', $registerFilterArray['info3']);
756
- echo $registerFilterArray['info3'];
757
- }
758
-
759
- if ($wppb_defaultOptions['aim'] == 'show'){
760
- $errorVar = '';
761
- $errorMark = '';
762
- if ($wppb_defaultOptions['aimRequired'] == 'yes'){
763
- $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
764
- if (isset($_POST['aim'])){
765
- if (trim($_POST['aim']) == ''){
766
- $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)."/>';
767
- $errorVar = ' errorHolder';
768
- }
769
- }
770
- }
771
-
772
- $localVar = '';
773
- if (isset($_POST['aim']))
774
- $localVar = $_POST['aim'];
775
- $registerFilterArray['info4'] = '
776
- <p class="form-aim'.$errorVar.'">
777
- <label for="aim">'. __('AIM', 'profilebuilder') .$errorMark.'</label>
778
- <input class="text-input" name="aim" type="text" id="aim" value="'.trim($localVar).'" />
779
- </p><!-- .form-aim -->';
780
- $registerFilterArray['info4'] = apply_filters('wppb_register_content_info4', $registerFilterArray['info4']);
781
- echo $registerFilterArray['info4'];
782
- }
783
-
784
- if ($wppb_defaultOptions['yahoo'] == 'show'){
785
- $errorVar = '';
786
- $errorMark = '';
787
- if ($wppb_defaultOptions['yahooRequired'] == 'yes'){
788
- $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
789
- if (isset($_POST['yim'])){
790
- if (trim($_POST['yim']) == ''){
791
- $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)."/>';
792
- $errorVar = ' errorHolder';
793
- }
794
- }
795
- }
796
-
797
- $localVar = '';
798
- if (isset($_POST['yim']))
799
- $localVar = $_POST['yim'];
800
- $registerFilterArray['info5'] = '
801
- <p class="form-yim'.$errorVar.'">
802
- <label for="yim">'. __('Yahoo IM', 'profilebuilder') .$errorMark.'</label>
803
- <input class="text-input" name="yim" type="text" id="yim" value="'.trim($localVar).'" />
804
- </p><!-- .form-yim -->';
805
- $registerFilterArray['info5'] = apply_filters('wppb_register_content_info5', $registerFilterArray['info5']);
806
- echo $registerFilterArray['info5'];
807
- }
808
-
809
- if ($wppb_defaultOptions['jabber'] == 'show'){
810
- $errorVar = '';
811
- $errorMark = '';
812
- if ($wppb_defaultOptions['jabberRequired'] == 'yes'){
813
- $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
814
- if (isset($_POST['jabber'])){
815
- if (trim($_POST['jabber']) == ''){
816
- $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)."/>';
817
- $errorVar = ' errorHolder';
818
- }
819
- }
820
- }
821
-
822
- $localVar = '';
823
- if (isset($_POST['jabber']))
824
- $localVar = $_POST['jabber'];
825
- $registerFilterArray['info6'] = '
826
- <p class="form-jabber'.$errorVar.'">
827
- <label for="jabber">'. __('Jabber / Google Talk', 'profilebuilder') .$errorMark.'</label>
828
- <input class="text-input" name="jabber" type="text" id="jabber" value="'.trim($localVar).'" />
829
- </p><!-- .form-jabber -->';
830
- $registerFilterArray['info6'] = apply_filters('wppb_register_content_info6', $registerFilterArray['info6']);
831
- echo $registerFilterArray['info6'];
832
- }
833
-
834
- $registerFilterArray['ay1'] = '<p class="registerAboutYourselfHeader"><strong>'. __('About Yourself', 'profilebuilder') .'</strong></p>';
835
- $registerFilterArray['ay1'] = apply_filters('wppb_register_content_about_yourself1', $registerFilterArray['ay1']);
836
- echo $registerFilterArray['ay1'];
837
-
838
- if ($wppb_defaultOptions['bio'] == 'show'){
839
- $errorVar = '';
840
- $errorMark = '';
841
- if ($wppb_defaultOptions['bioRequired'] == 'yes'){
842
- $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
843
- if (isset($_POST['description'])){
844
- if (trim($_POST['description']) == ''){
845
- $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)."/>';
846
- $errorVar = ' errorHolder';
847
- }
848
- }
849
- }
850
-
851
- $localVar = '';
852
- if (isset($_POST['description']))
853
- $localVar = $_POST['description'];
854
- $registerFilterArray['ay2'] = '
855
- <p class="form-description'.$errorVar.'">
856
- <label for="description">'. __('Biographical Info', 'profilebuilder') .$errorMark.'</label>
857
- <textarea class="text-input" name="description" id="description" rows="5" cols="30">'.trim($localVar).'</textarea>
858
- </p><!-- .form-description -->';
859
- $registerFilterArray['ay2'] = apply_filters('wppb_register_content_about_yourself2', $registerFilterArray['ay2']);
860
- echo $registerFilterArray['ay2'];
861
- }
862
-
863
- if ($wppb_defaultOptions['password'] == 'show'){
864
- $errorMark = '';
865
- if ($wppb_defaultOptions['passwordRequired'] == 'yes'){
866
- $errorMark = '<font color="red" title="This field is required for registration.">*</font>';
867
- }
868
-
869
- $localVar1 = '';
870
- if (isset($_POST['passw1']))
871
- $localVar1 = $_POST['passw1'];
872
- $localVar2 = '';
873
- if (isset($_POST['passw2']))
874
- $localVar2 = $_POST['passw2'];
875
- $registerFilterArray['ay3'] = '
876
- <p class="form-password">
877
- <label for="pass1">'. __('Password', 'profilebuilder') .$errorMark.'</label>
878
- <input class="text-input" name="passw1" type="password" id="pass1" value="'.trim($localVar).'" />
879
- </p><!-- .form-password -->
880
-
881
- <p class="form-password">
882
- <label for="pass2">'. __('Repeat Password', 'profilebuilder') .$errorMark.'</label>
883
- <input class="text-input" name="passw2" type="password" id="pass2" value="'.trim($localVar2).'" />
884
- </p><!-- .form-password -->';
885
- $registerFilterArray['ay3'] = apply_filters('wppb_register_content_about_yourself3', $registerFilterArray['ay3']);
886
- echo $registerFilterArray['ay3'];
887
- }
888
-
889
- $wppb_premium = wppb_plugin_dir . '/premium/functions/';
890
- if (file_exists ( $wppb_premium.'extra.fields.php' )){
891
- require_once($wppb_premium.'extra.fields.php');
892
- register_user_extra_fields($error, $_POST, $extraFieldsErrorHolder);
893
- }
894
-
895
- if (isset($_POST['send_credentials_via_email']))
896
- $checkedVar = ' checked';
897
- else $checkedVar = '';
898
- $registerFilterArray['confirmationEmailForm'] = '
899
- <p class="send-confirmation-email">
900
- <label for="send-confirmation-email">
901
- <input id="send_credentials_via_email" type="checkbox" name="send_credentials_via_email" value="sending"'. $checkedVar .'/>
902
- <span class="wppb-description-delimiter"> '. __('Send these credentials via email.', 'profilebuilder') .'</span>
903
- </label>
904
- </p><!-- .send-confirmation-email -->';
905
- $registerFilterArray['confirmationEmailForm'] = apply_filters('wppb_register_confirmation_email_form', $registerFilterArray['confirmationEmailForm']);
906
- echo $registerFilterArray['confirmationEmailForm'];
907
- ?>
908
-
909
- <p class="form-submit">
910
- <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'); ?>" />
911
- <input name="action" type="hidden" id="action" value="adduser" />
912
- </p><!-- .form-submit -->
913
- <?php
914
- wp_nonce_field('verify_true_registration','register_nonce_field');
915
- ?>
916
- </form><!-- #adduser -->
917
-
918
- <?php
919
- endif;
920
- endif;
921
-
922
- /* use this action hook to add extra content after the register form. */
923
- do_action( 'wppb_after_register_fields' );
924
- ?>
925
-
926
- </div>
927
- <?php
928
- $output = ob_get_contents();
929
- ob_end_clean();
930
-
931
- $registerFilterArray = apply_filters('wppb_register', $registerFilterArray);
932
-
933
- return $output;
934
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
935
  ?>
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
+
11
+ global $wppb_shortcode_on_front;
12
+
13
+ $wppb_shortcode_on_front = true;
14
+ $agreed = true;
15
+ $new_user = 'no';
16
+ $registerFilterArray = array();
17
+ $registerFilterArray2 = array();
18
+ $uploadExt = array();
19
+ $extraFieldsErrorHolder = array(); //we will use this array to store the ID's of the extra-fields left uncompleted
20
+ get_currentuserinfo();
21
+
22
+ /* variables used to verify if all required fields were submitted*/
23
+ $firstnameComplete = 'yes';
24
+ $lastnameComplete = 'yes';
25
+ $nicknameComplete = 'yes';
26
+ $websiteComplete = 'yes';
27
+ $aimComplete = 'yes';
28
+ $yahooComplete = 'yes';
29
+ $jabberComplete = 'yes';
30
+ $bioComplete = 'yes';
31
+ /* END variables used to verify if all required fields were submitted*/
32
+
33
+
34
+ /* Load registration file. */
35
+ require_once( ABSPATH . WPINC . '/registration.php' );
36
+
37
+ /* Check if users can register. */
38
+ $registration = get_option( 'users_can_register' );
39
+
40
+
41
+ //fallback if the file was largen then post_max_size, case in which no errors can be saved in $_FILES[fileName]['error']
42
+ if (empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
43
+ $registerFilterArray['noPostError'] = '
44
+ <p class="error">'.
45
+ __('The information size you were trying to submit was larger than', 'profilebuilder') .' '. WPPB_SERVER_MAX_UPLOAD_SIZE_MEGA .'b!<br/>'.
46
+ __('This is usually caused by a large file(s) trying to be uploaded.', 'profilebuilder') .'<br/>'.
47
+ __('Since it was also larger than', 'profilebuilder') .' '. WPPB_SERVER_MAX_POST_SIZE_MEGA .'b, '. __('no additional information is available.', 'profilebuilder'). '<br/>'.
48
+ __('The user was NOT created!', 'profilebuilder') .
49
+ '</p>';
50
+ $registerFilterArray['noPostError'] = apply_filters('wppb_register_no_post_error_message', $registerFilterArray['noPostError']);
51
+ echo $registerFilterArray['noPostError'];
52
+ }
53
+
54
+ /* If user registered, input info. */
55
+ if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'adduser' && wp_verify_nonce($_POST['register_nonce_field'],'verify_true_registration') ) {
56
+ //global $wp_roles;
57
+
58
+ //get value sent in the shortcode as parameter, default to "subscriber" if not set
59
+ extract(shortcode_atts(array('role' => 'subscriber'), $atts));
60
+
61
+ //check if the specified role exists in the database, else fall back to the "safe-zone"
62
+ $found = get_role($role);
63
+
64
+ if ($found != null)
65
+ $aprovedRole = $role;
66
+ else $aprovedRole = get_option( 'default_role' );
67
+
68
+ /* preset the values in case some are not submitted */
69
+ $user_pass = '';
70
+ if (isset($_POST['passw1']))
71
+ $user_pass = esc_attr( $_POST['passw1'] );
72
+ $user_name = '';
73
+ if (isset($_POST['user_name']))
74
+ $user_name = trim ($_POST['user_name']);
75
+ $first_name = '';
76
+ if (isset($_POST['first_name']))
77
+ $first_name = trim ($_POST['first_name']);
78
+ $last_name = '';
79
+ if (isset($_POST['last_name']))
80
+ $last_name = trim ($_POST['last_name']);
81
+ $nickname = '';
82
+ if (isset($_POST['nickname']))
83
+ $nickname = trim ($_POST['nickname']);
84
+ $email = '';
85
+ if (isset($_POST['email']))
86
+ $email = trim ($_POST['email']);
87
+ $website = '';
88
+ if (isset($_POST['website']))
89
+ $website = trim ($_POST['website']);
90
+ $aim = '';
91
+ if (isset($_POST['aim']))
92
+ $aim = trim ($_POST['aim']);
93
+ $yim = '';
94
+ if (isset($_POST['yim']))
95
+ $yim = trim ($_POST['yim']);
96
+ $jabber = '';
97
+ if (isset($_POST['jabber']))
98
+ $jabber = trim ($_POST['jabber']);
99
+ $description = '';
100
+ if (isset($_POST['description']))
101
+ $description = trim ($_POST['description']);
102
+
103
+ /* use filters to modify (if needed) the posted data before creating the user-data */
104
+ $user_pass = apply_filters('wppb_register_posted_password', $user_pass);
105
+ $user_name = apply_filters('wppb_register_posted_email', $user_name);
106
+ $first_name = apply_filters('wppb_register_posted_first_name', $first_name);
107
+ $last_name = apply_filters('wppb_register_posted_last_name', $last_name);
108
+ $nickname = apply_filters('wppb_register_posted_nickname', $nickname);
109
+ $email = apply_filters('wppb_register_posted_email', $email);
110
+ $website = apply_filters('wppb_register_posted_website', $website);
111
+ $aim = apply_filters('wppb_register_posted_aim', $aim);
112
+ $yim = apply_filters('wppb_register_posted_yahoo', $yim);
113
+ $jabber = apply_filters('wppb_register_posted_jabber', $jabber);
114
+ $description = apply_filters('wppb_register_posted_bio', $description);
115
+ /* END use filters to modify (if needed) the posted data before creating the user-data */
116
+
117
+ $userdata = array(
118
+ 'user_pass' => $user_pass,
119
+ 'user_login' => esc_attr( $_POST['user_name'] ),
120
+ 'first_name' => esc_attr( $_POST['first_name'] ),
121
+ 'last_name' => esc_attr( $_POST['last_name'] ),
122
+ 'nickname' => esc_attr( $_POST['nickname'] ),
123
+ 'user_email' => esc_attr( $_POST['email'] ),
124
+ 'user_url' => esc_attr( $_POST['website'] ),
125
+ 'aim' => esc_attr( $_POST['aim'] ),
126
+ 'yim' => esc_attr( $_POST['yim'] ),
127
+ 'jabber' => esc_attr( $_POST['jabber'] ),
128
+ 'description' => esc_attr( $_POST['description'] ),
129
+ 'role' => $aprovedRole);
130
+ $userdata = apply_filters('wppb_register_userdata', $userdata);
131
+
132
+ //get required and shown fields
133
+ $wppb_defaultOptions = get_option('wppb_default_settings');
134
+
135
+ //check if the user agreed to the terms and conditions (if it was set)
136
+ $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/';
137
+ if (file_exists ( $wppb_premium.'extra.fields.php' )){
138
+ $wppbFetchArray = get_option('wppb_custom_fields');
139
+ foreach ( $wppbFetchArray as $key => $value){
140
+ switch ($value['item_type']) {
141
+ case "agreeToTerms":{
142
+ $agreed = false;
143
+ if ( (isset($_POST[$value['item_id'].$value['id']] )) && ($_POST[$value['item_id'].$value['id']] == 'agree'))
144
+ $agreed = true;
145
+ break;
146
+ }
147
+ }
148
+ }
149
+ }
150
+
151
+ $registerFilterArray['extraError'] = ''; //this is for creating extra error message and bypassing registration
152
+ $registerFilterArray['extraError'] = apply_filters('wppb_register_extra_error', $registerFilterArray['extraError']);
153
+
154
+ /* check if all the required fields were completed */
155
+ if($wppb_defaultOptions['firstname'] == 'show'){
156
+ if (($wppb_defaultOptions['firstnameRequired'] == 'yes') && (trim($_POST['first_name']) == ''))
157
+ $firstnameComplete = 'no';
158
+ }elseif($wppb_defaultOptions['lastname'] == 'show'){
159
+ if (($wppb_defaultOptions['lastnameRequired'] == 'yes') && (trim($_POST['last_name']) == ''))
160
+ $lastnameComplete = 'no';
161
+ }elseif($wppb_defaultOptions['nickname'] == 'show'){
162
+ if (($wppb_defaultOptions['nicknameRequired'] == 'yes') && (trim($_POST['nickname']) == ''))
163
+ $nicknameComplete = 'no';
164
+ }elseif($wppb_defaultOptions['website'] == 'show'){
165
+ if (($wppb_defaultOptions['websiteRequired'] == 'yes') && (trim($_POST['website']) == ''))
166
+ $websiteComplete = 'no';
167
+ }elseif($wppb_defaultOptions['aim'] == 'show'){
168
+ if (($wppb_defaultOptions['aimRequired'] == 'yes') && (trim($_POST['aim']) == ''))
169
+ $aimComplete = 'no';
170
+ }elseif($wppb_defaultOptions['yahoo'] == 'show'){
171
+ if (($wppb_defaultOptions['yahooRequired'] == 'yes') && (trim($_POST['yahoo']) == ''))
172
+ $yahooComplete = 'no';
173
+ }elseif($wppb_defaultOptions['jabber'] == 'show'){
174
+ if (($wppb_defaultOptions['jabberRequired'] == 'yes') && (trim($_POST['jabber']) == ''))
175
+ $jabberComplete = 'no';
176
+ }elseif($wppb_defaultOptions['bio'] == 'show'){
177
+ if (($wppb_defaultOptions['bioRequired'] == 'yes') && (trim($_POST['description']) == ''))
178
+ $bioComplete = 'no';
179
+ }
180
+
181
+ // check the extra fields also
182
+ $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/';
183
+ if (file_exists ( $wppb_premium.'extra.fields.php' )){
184
+ $wppbFetchArray = get_option('wppb_custom_fields');
185
+ foreach ( $wppbFetchArray as $key => $value){
186
+ switch ($value['item_type']) {
187
+ case "input":{
188
+ $_POST[$value['item_id'].$value['id']] = apply_filters('wppb_register_input_custom_field_'.$value['id'], $_POST[$value['item_id'].$value['id']]);
189
+ if (isset($value['item_required'])){
190
+ if ($value['item_required'] == 'yes'){
191
+ if (trim($_POST[$value['item_id'].$value['id']]) == '')
192
+ array_push($extraFieldsErrorHolder, $value['id']);
193
+ }
194
+ }
195
+ break;
196
+ }
197
+ case "checkbox":{
198
+ $checkboxOption = '';
199
+ $checkboxValue = explode(',', $value['item_options']);
200
+ foreach($checkboxValue as $thisValue){
201
+ $thisValue = str_replace(' ', '#@space@#', $thisValue); //we need to escape the space-codification we sent earlier in the post
202
+ if (isset($_POST[$thisValue.$value['id']])){
203
+ $localValue = str_replace('#@space@#', ' ', $_POST[$thisValue.$value['id']]);
204
+ $checkboxOption = $checkboxOption.$localValue.',';
205
+ }
206
+ }
207
+
208
+ if (isset($value['item_required'])){
209
+ if ($value['item_required'] == 'yes'){
210
+ if (trim($checkboxOption) == '')
211
+ array_push($extraFieldsErrorHolder, $value['id']);
212
+ }
213
+ }
214
+ break;
215
+ }
216
+ case "radio":{
217
+ if (isset($value['item_required'])){
218
+ if ($value['item_required'] == 'yes'){
219
+ if (trim($_POST[$value['item_id'].$value['id']]) == '')
220
+ array_push($extraFieldsErrorHolder, $value['id']);
221
+ }
222
+ }
223
+ break;
224
+ }
225
+ case "select":{
226
+ if (isset($value['item_required'])){
227
+ if ($value['item_required'] == 'yes'){
228
+ if (trim($_POST[$value['item_id'].$value['id']]) == '')
229
+ array_push($extraFieldsErrorHolder, $value['id']);
230
+ }
231
+ }
232
+ break;
233
+ }
234
+ case "countrySelect":{
235
+ if (isset($value['item_required'])){
236
+ if ($value['item_required'] == 'yes'){
237
+ if (trim($_POST[$value['item_id'].$value['id']]) == '')
238
+ array_push($extraFieldsErrorHolder, $value['id']);
239
+ }
240
+ }
241
+ break;
242
+ }
243
+ case "timeZone":{
244
+ if (isset($value['item_required'])){
245
+ if ($value['item_required'] == 'yes'){
246
+ if (trim($_POST[$value['item_id'].$value['id']]) == '')
247
+ array_push($extraFieldsErrorHolder, $value['id']);
248
+ }
249
+ }
250
+ break;
251
+ }
252
+ case "datepicker":{
253
+ if (isset($value['item_required'])){
254
+ if ($value['item_required'] == 'yes'){
255
+ if (trim($_POST[$value['item_id'].$value['id']]) == '')
256
+ array_push($extraFieldsErrorHolder, $value['id']);
257
+ }
258
+ }
259
+ break;
260
+ }
261
+ case "textarea":{
262
+ if (isset($value['item_required'])){
263
+ if ($value['item_required'] == 'yes'){
264
+ if (trim($_POST[$value['item_id'].$value['id']]) == '')
265
+ array_push($extraFieldsErrorHolder, $value['id']);
266
+ }
267
+ }
268
+ break;
269
+ }
270
+ case "upload":{
271
+ $uploadedfile = $value['item_type'].$value['id'];
272
+
273
+ if ( (basename( $_FILES[$uploadedfile]['name']) == '')){
274
+ if (isset($value['item_required'])){
275
+ if ($value['item_required'] == 'yes')
276
+ array_push($extraFieldsErrorHolder, $value['id']);
277
+ }
278
+ }elseif ( (basename( $_FILES[$uploadedfile]['name']) != '')){
279
+ //get allowed file types
280
+ if (($value['item_options'] != NULL) || ($value['item_options'] != '')){
281
+ $allFiles = false;
282
+ $extensions = explode(',', $value['item_options']);
283
+ foreach($extensions as $key2 => $value2)
284
+ $extensions[$key2] = trim($value2);
285
+ }else
286
+ $allFiles = true;
287
+
288
+ $thisFileExtStart = strrpos($_FILES[$uploadedfile]['name'], '.');
289
+ $thisFileExt = substr($_FILES[$uploadedfile]['name'], $thisFileExtStart);
290
+
291
+ if (($allFiles == false) && (!in_array($thisFileExt, $extensions))){
292
+ array_push($uploadExt, basename( $_FILES[$uploadedfile]['name']));
293
+ $allowedExtensions = '';
294
+ (int)$nrOfExt = count($extensions)-2;
295
+ foreach($extensions as $key2 => $value2){
296
+ $allowedExtensions .= $value2;
297
+ if ($key2 <= $nrOfExt)
298
+ $allowedExtensions .= ', ';
299
+
300
+ }
301
+ }
302
+ }
303
+ break;
304
+ }
305
+ case "avatar":{
306
+ $uploadedfile = $value['item_type'].$value['id'];
307
+
308
+ if ( (basename( $_FILES[$uploadedfile]['name']) == '')){
309
+ 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'))
310
+ if (isset($value['item_required'])){
311
+ if ($value['item_required'] == 'yes')
312
+ array_push($extraFieldsErrorHolder, $value['id']);
313
+ }
314
+ }
315
+ break;
316
+ }
317
+ }
318
+ }
319
+ }
320
+
321
+ /* END check if all the required fields were completed */
322
+ if ($registerFilterArray['extraError'] != '')
323
+ $error = $registerFilterArray['extraError'];
324
+ elseif ( !$userdata['user_login'] )
325
+ $error = __('A username is required for registration.', 'profilebuilder');
326
+ elseif ( username_exists($userdata['user_login']) )
327
+ $error = __('Sorry, that username already exists!', 'profilebuilder');
328
+ elseif ( !is_email($userdata['user_email'], true) )
329
+ $error = __('You must enter a valid email address.', 'profilebuilder');
330
+ elseif ( email_exists($userdata['user_email']) )
331
+ $error = __('Sorry, that email address is already used!', 'profilebuilder');
332
+ elseif (( empty($_POST['passw1'] ) || empty( $_POST['passw2'] )) || ( $_POST['passw1'] != $_POST['passw2'] )){
333
+ if ( empty($_POST['passw1'] ) || empty( $_POST['passw2'] )) //verify if the user has completed both password fields
334
+ $error = __('You didn\'t complete one of the password-fields!', 'profilebuilder');
335
+ elseif ( $_POST['passw1'] != $_POST['passw2'] ) //verify if the the password and the retyped password are a match
336
+ $error = __('The entered passwords don\'t match!', 'profilebuilder');
337
+ }elseif(count($uploadExt) > 0){
338
+ $error ='<p class="semi-saved">'.
339
+ __('There was an error while trying to upload the following attachment(s)', 'profilebuilder') .': <span class="error">';
340
+ foreach ($uploadExt as $key5 => $name5){
341
+ $lastOne++;
342
+ $error .= $name5;
343
+ if (count($uploadExt)-$lastOne > 0)
344
+ $error .= ';<span style="padding-left:10px"></span>';
345
+ }
346
+ $error .= '</span><br/>'. __('Only files with the following extension(s) can be uploaded:', 'profilebuilder') .' <span class="error">'.$allowedExtensions.'</span><br/><span class="error">'. __('The account was NOT created!', 'profilebuilder') .'</span>
347
+ </p>';
348
+ }
349
+ elseif ( $agreed == false )
350
+ $error = __('You must agree to the terms and conditions before registering!', 'profilebuilder');
351
+ elseif(($firstnameComplete == 'no' || $lastnameComplete == 'no' || $nicknameComplete == 'no' || $websiteComplete == 'no' || $aimComplete == 'no' || $yahooComplete == 'no' || $jabberComplete == 'no' || $bioComplete == 'no' ) || !empty($extraFieldsErrorHolder))
352
+ $error = __('The account was NOT created!', 'profilebuilder') .'<br/>'. __('(Several required fields were left uncompleted)', 'profilebuilder');
353
+ else{
354
+ $registered_name = $_POST['user_name'];
355
+ $new_user = wp_insert_user( $userdata );
356
+
357
+ /* add the extra profile information */
358
+ $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/';
359
+ if (file_exists ( $wppb_premium.'extra.fields.php' )){
360
+ $wppbFetchArray = get_option('wppb_custom_fields');
361
+ foreach ( $wppbFetchArray as $key => $value){
362
+ switch ($value['item_type']) {
363
+ case "input":{
364
+ add_user_meta( $new_user, $value['item_metaName'], esc_attr($_POST[$value['item_id'].$value['id']]) );
365
+ break;
366
+ }
367
+ case "hiddenInput":{
368
+ add_user_meta( $new_user, $value['item_metaName'], esc_attr($_POST[$value['item_id'].$value['id']]) );
369
+ break;
370
+ }
371
+ case "checkbox":{
372
+ $checkboxOption = '';
373
+ $checkboxValue = explode(',', $value['item_options']);
374
+ foreach($checkboxValue as $thisValue){
375
+ $thisValue = str_replace(' ', '#@space@#', $thisValue); //we need to escape the space-codification we sent earlier in the post
376
+ if (isset($_POST[$thisValue.$value['id']])){
377
+ $localValue = str_replace('#@space@#', ' ', $_POST[$thisValue.$value['id']]);
378
+ $checkboxOption = $checkboxOption.$localValue.',';
379
+ }
380
+ }
381
+
382
+ add_user_meta( $new_user, $value['item_metaName'], $checkboxOption );
383
+ break;
384
+ }
385
+ case "radio":{
386
+ add_user_meta( $new_user, $value['item_metaName'], $_POST[$value['item_id'].$value['id']] );
387
+ break;
388
+ }
389
+ case "select":{
390
+ add_user_meta( $new_user, $value['item_metaName'], $_POST[$value['item_id'].$value['id']] );
391
+ break;
392
+ }
393
+ case "countrySelect":{
394
+ update_user_meta( $new_user, $value['item_metaName'], $_POST[$value['item_id'].$value['id']] );
395
+ break;
396
+ }
397
+ case "timeZone":{
398
+ update_user_meta( $new_user, $value['item_metaName'], $_POST[$value['item_id'].$value['id']] );
399
+ break;
400
+ }
401
+ case "datepicker":{
402
+ update_user_meta( $new_user, $value['item_metaName'], $_POST[$value['item_id'].$value['id']] );
403
+ break;
404
+ }
405
+ case "textarea":{
406
+ add_user_meta( $new_user, $value['item_metaName'], esc_attr($_POST[$value['item_id'].$value['id']]) );
407
+ break;
408
+ }
409
+ case "upload":{
410
+ $uploadedfile = $value['item_type'].$value['id'];
411
+
412
+ //first we need to verify if we don't try to upload a 0b or 0 length file
413
+ if ( (basename( $_FILES[$uploadedfile]['name']) != '')){
414
+
415
+ //second we need to verify if the uploaded file size is less then the set file size in php.ini
416
+ if (($_FILES[$uploadedfile]['size'] < WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE) && ($_FILES[$uploadedfile]['size'] !=0)){
417
+ //we need to prepare the basename of the file, so that ' becomes ` as ' gives an error
418
+ $fileName = basename( $_FILES[$uploadedfile]['name']);
419
+ $finalFileName = '';
420
+
421
+ for ($i=0; $i < strlen($fileName); $i++){
422
+ if ($fileName[$i] == "'")
423
+ $finalFileName .= '`';
424
+ else $finalFileName .= $fileName[$i];
425
+ }
426
+
427
+ //create the target path for uploading
428
+ $wpUploadPath = wp_upload_dir(); // Array of key => value pairs
429
+ $target_path = $wpUploadPath['basedir']."/profile_builder/attachments/";
430
+ $target_path = $target_path . 'userID_'.$new_user.'_attachment_'. $finalFileName;
431
+
432
+ if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)){
433
+ //$upFile = get_bloginfo('home').'/'.$target_path;
434
+ $upFile = $wpUploadPath['baseurl'].'/profile_builder/attachments/userID_'.$new_user.'_attachment_'. $finalFileName;
435
+ add_user_meta( $new_user, $value['item_metaName'], $upFile );
436
+ $pictureUpload = 'yes';
437
+ }
438
+ }
439
+ }
440
+ break;
441
+ }
442
+ case "avatar":{
443
+
444
+ $uploadedfile = $value['item_type'].$value['id'];
445
+ $wpUploadPath = wp_upload_dir(); // Array of key => value pairs
446
+ $target_path_original = $wpUploadPath['basedir']."/profile_builder/avatars/";
447
+ $fileName = $_FILES[$uploadedfile]['name'];
448
+ $finalFileName = '';
449
+
450
+ for ($i=0; $i < strlen($fileName); $i++){
451
+ if ($fileName[$i] == "'")
452
+ $finalFileName .= '`';
453
+ elseif ($fileName[$i] == ' ')
454
+ $finalFileName .= '_';
455
+ else $finalFileName .= $fileName[$i];
456
+ }
457
+
458
+ $fileName = $finalFileName;
459
+
460
+ $target_path = $target_path_original . 'userID_'.$new_user.'_originalAvatar_'. $fileName;
461
+
462
+ /* when trying to upload file, be sure it's one of the accepted image file-types */
463
+ 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'] < WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE) && ($_FILES[$uploadedfile]['size'] !=0)) ){
464
+ $wp_filetype = wp_check_filetype(basename( $_FILES[$uploadedfile]['name']), null );
465
+ $attachment = array('post_mime_type' => $wp_filetype['type'],
466
+ 'post_title' => $fileName, //preg_replace('/\.[^.]+$/', '', basename($_FILES[$uploadedfile]['name'])),
467
+ 'post_content' => '',
468
+ 'post_status' => 'inherit'
469
+ );
470
+
471
+
472
+ $attach_id = wp_insert_attachment( $attachment, $target_path);
473
+
474
+ $upFile = image_downsize( $attach_id, 'thumbnail' );
475
+ $upFile = $upFile[0];
476
+
477
+ //if file upload succeded
478
+ if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)){
479
+ add_user_meta( $new_user, $value['item_metaName'], $upFile );
480
+ wppb_resize_avatar($new_user);
481
+ $avatarUpload = 'yes';
482
+ }
483
+ else $avatarUpload = 'no';
484
+ }
485
+ if (($_FILES[$uploadedfile]['type'] == ''))
486
+ $avatarUpload = 'yes';
487
+
488
+ break;
489
+ }
490
+ }
491
+ }
492
+ }
493
+
494
+
495
+ //send an email to the admin regarding each and every new subscriber
496
+ $bloginfo = get_bloginfo( 'name' );
497
+ $registerFilterArray['adminMessageOnRegistration'] = '';
498
+ $registerFilterArray['adminMessageOnRegistration'] = __('New subscriber on', 'profilebuilder') .' '.$bloginfo . "\r\n\r\n";
499
+ $registerFilterArray['adminMessageOnRegistration'] .= __('Username', 'profilebuilder') .': '. esc_attr($_POST['user_name']) . "\r\n";
500
+ $registerFilterArray['adminMessageOnRegistration'] .= __('E-mail', 'profilebuilder') .': '. esc_attr($_POST['email']) . "\r\n";
501
+ $registerFilterArray['adminMessageOnRegistration'] = apply_filters('wppb_register_admin_message_content', $registerFilterArray['adminMessageOnRegistration']);
502
+
503
+ $registerFilterArray['adminMessageOnRegistrationTitle'] = '['. $bloginfo .']'. __('A new subscriber has (been) registered!');
504
+ $registerFilterArray['adminMessageOnRegistrationTitle'] = apply_filters ('wppb_register_admin_message_title', $registerFilterArray['adminMessageOnRegistrationTitle']);
505
+
506
+ if (trim($registerFilterArray['adminMessageOnRegistration']) != '')
507
+ wp_mail(get_option('admin_email'), $registerFilterArray['adminMessageOnRegistrationTitle'], $registerFilterArray['adminMessageOnRegistration']);
508
+
509
+
510
+ //send an email to the newly registered user, if this option was selected
511
+ if (isset($_POST['send_credentials_via_email']) && ($_POST['send_credentials_via_email'] == 'sending')){
512
+ //change these variables to modify sent email message, destination and source.
513
+ $email = $_POST['email'];
514
+ $mailPassword = $_POST['passw1'];
515
+ $mailUsername = $_POST['user_name'];
516
+
517
+ $registerFilterArray['userMessageFrom'] = get_bloginfo('name');
518
+ $registerFilterArray['userMessageFrom'] = apply_filters('wppb_register_from_email_content', $registerFilterArray['userMessageFrom']);
519
+
520
+ $registerFilterArray['userMessageSubject'] = 'A new account has been created for you.';
521
+ $registerFilterArray['userMessageSubject'] = apply_filters('wppb_register_subject_email_content', $registerFilterArray['userMessageSubject']);
522
+
523
+ $registerFilterArray['userMessageContent'] = 'Welcome to '.$registerFilterArray['userMessageFrom'].'. Your username is:'.$mailUsername.' and password:'.$mailPassword;
524
+ $registerFilterArray['userMessageContent'] = apply_filters('wppb_register_email_content', $registerFilterArray['userMessageContent']);
525
+
526
+ $messageSent = wp_mail( $email, $registerFilterArray['userMessageSubject'], $registerFilterArray['userMessageContent']);
527
+ if( $messageSent == TRUE)
528
+ $sentEmailStatus = 2;
529
+ else
530
+ $sentEmailStatus = 1;
531
+ }
532
+
533
+ }
534
+ }
535
+
536
+ ?>
537
+ <div class="wppb_holder" id="wppb_register">
538
+ <?php
539
+ if ( is_user_logged_in() && !current_user_can( 'create_users' ) ) :
540
+
541
+ global $user_ID;
542
+ $login = get_userdata( $user_ID );
543
+ if($login->display_name == ''){
544
+ $login->display_name = $login->user_login;
545
+ }
546
+ $registerFilterArray['loginLogoutError'] = '
547
+ <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 -->';
548
+ $registerFilterArray['loginLogoutError'] = apply_filters('wppb_register_have_account_alert', $registerFilterArray['loginLogoutError']);
549
+ echo $registerFilterArray['loginLogoutError'];
550
+
551
+ elseif ( $new_user != 'no' ) :
552
+ if ( current_user_can( 'create_users' ) ){
553
+ $registerFilterArray['registrationMessage1'] = '
554
+ <p class="success">'. __('A user account has been created for', 'profilebuilder') .' '. $registered_name. '.</p><!-- .success -->';
555
+ $registerFilterArray['registrationMessage1'] = apply_filters('wppb_register_account_created1', $registerFilterArray['registrationMessage1']);
556
+ echo $registerFilterArray['registrationMessage1'];
557
+
558
+ $wppb_addons = WPPB_PLUGIN_DIR . '/premium/addon/';
559
+ if (file_exists ( $wppb_addons.'addon.php' )){
560
+ //check to see if the redirecting addon is present and activated
561
+ $wppb_premium_addon_settings = get_option('wppb_premium_addon_settings');
562
+ if ($wppb_premium_addon_settings['customRedirect'] == 'show'){
563
+ //check to see if the redirect location is not an empty string and is activated
564
+ $customRedirectSettings = get_option('customRedirectSettings');
565
+ if ((trim($customRedirectSettings['afterRegisterTarget']) != '') && ($customRedirectSettings['afterRegister'] == 'yes')){
566
+ $redirectLink = trim($customRedirectSettings['afterRegisterTarget']);
567
+ $findHttp = strpos($redirectLink, 'http');
568
+ if ($findHttp === false)
569
+ $redirectLink = 'http://'. $redirectLink;
570
+ }
571
+ }
572
+ }
573
+ $registerFilterArray['redirectMessage1'] = '<font color="black">You will soon be redirected automatically. If you see this page for more than 3 seconds, please click <a href="'.$redirectLink.'">here</a>.<meta http-equiv="Refresh" content="3;url='.$redirectLink.'" /></font><br/><br/>';
574
+ $registerFilterArray['redirectMessage1'] = apply_filters('wppb_register_redirect_after_creation1', $registerFilterArray['redirectMessage1']);
575
+ echo $registerFilterArray['redirectMessage1'];
576
+
577
+ }else{
578
+ $registerFilterArray['registrationMessage2'] = '
579
+ <p class="success">'. __('Thank you for registering', 'profilebuilder') .' '. $registered_name .'.</p><!-- .success -->';
580
+ $registerFilterArray['registrationMessage2'] = apply_filters('wppb_register_account_created2', $registerFilterArray['registrationMessage2']);
581
+ echo $registerFilterArray['registrationMessage2'];
582
+
583
+ $wppb_addons = WPPB_PLUGIN_DIR . '/premium/addon/';
584
+ if (file_exists ( $wppb_addons.'addon.php' )){
585
+ //check to see if the redirecting addon is present and activated
586
+ $wppb_premium_addon_settings = get_option('wppb_premium_addon_settings');
587
+ if ($wppb_premium_addon_settings['customRedirect'] == 'show'){
588
+ //check to see if the redirect location is not an empty string and is activated
589
+ $customRedirectSettings = get_option('customRedirectSettings');
590
+ if ((trim($customRedirectSettings['afterRegisterTarget']) != '') && ($customRedirectSettings['afterRegister'] == 'yes')){
591
+ $redirectLink = trim($customRedirectSettings['afterRegisterTarget']);
592
+ $findHttp = strpos($redirectLink, 'http');
593
+ if ($findHttp === false)
594
+ $redirectLink = 'http://'. $redirectLink;
595
+ }
596
+ }
597
+ }
598
+ $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/>';
599
+ $registerFilterArray['redirectMessage2'] = apply_filters('wppb_register_redirect_after_creation2', $registerFilterArray['redirectMessage2']);
600
+ echo $registerFilterArray['redirectMessage2'];
601
+ }
602
+
603
+
604
+ if(isset($_POST['send_credentials_via_email'])){
605
+ if ($sentEmailStatus == 1){
606
+ $registerFilterArray['emailMessage1'] = '<p class="error">'. __('An error occured while trying to send the notification email.', 'profilebuilder') .'</p><!-- .error -->';
607
+ $registerFilterArray['emailMessage1'] = apply_filters('wppb_register_send_notification_email_fail', $registerFilterArray['emailMessage1']);
608
+ echo $registerFilterArray['emailMessage1'];
609
+ }elseif ($sentEmailStatus == 2){
610
+ $registerFilterArray['emailMessage2'] = '<p class="success">'. __('An email containing the username and password was successfully sent.', 'profilebuilder') .'</p><!-- .success -->';
611
+ $registerFilterArray['emailMessage2'] = apply_filters('wppb_register_send_notification_email_success', $registerFilterArray['emailMessage2']);
612
+ echo $registerFilterArray['emailMessage2'];
613
+ }
614
+ }
615
+ ?>
616
+ <?php
617
+ else :
618
+ if ( $error ) :
619
+ $registerFilterArray['errorMessage'] = '<p class="error">'. $error .'</p><!-- .error -->';
620
+ $registerFilterArray['errorMessage'] = apply_filters('wppb_register_error_messaging', $registerFilterArray['errorMessage']);
621
+ echo $registerFilterArray['errorMessage'];
622
+ endif;
623
+
624
+ if ( current_user_can( 'create_users' ) && $registration ) :
625
+ $registerFilterArray['alertMessage1'] = '<p class="alert">'. __('Users can register themselves or you can manually create users here.', 'profilebuilder') .'</p><!-- .alert -->';
626
+ $registerFilterArray['alertMessage1'] = apply_filters('wppb_register_alert_messaging1', $registerFilterArray['alertMessage1']);
627
+ echo $registerFilterArray['alertMessage1'];
628
+
629
+ elseif ( current_user_can( 'create_users' ) ) :
630
+ $registerFilterArray['alertMessage2'] = '<p class="alert">'. __('Users cannot currently register themselves, but you can manually create users here.', 'profilebuilder') .'</p><!-- .alert -->';
631
+ $registerFilterArray['alertMessage2'] = apply_filters('wppb_register_alert_messaging2', $registerFilterArray['alertMessage2']);
632
+ echo $registerFilterArray['alertMessage2'];
633
+
634
+ elseif ( !current_user_can( 'create_users' ) && !$registration) :
635
+ $registerFilterArray['alertMessage3'] = '<p class="alert">'. __('Only an administrator can add new users.', 'profilebuilder') .'</p><!-- .alert -->';
636
+ $registerFilterArray['alertMessage3'] = apply_filters('wppb_register_alert_messaging3', $registerFilterArray['alertMessage3']);
637
+ echo $registerFilterArray['alertMessage3'];
638
+ endif;
639
+
640
+ if ( $registration || current_user_can( 'create_users' ) ) :
641
+ /* use this action hook to add extra content before the register form. */
642
+ do_action( 'wppb_before_register_fields' );
643
+ ?>
644
+ <form enctype="multipart/form-data" method="post" id="adduser" class="user-forms" action="http://<?php echo $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>">
645
+ <?php
646
+ echo '<input type="hidden" name="MAX_FILE_SIZE" value="'.WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE.'" /><!-- set the MAX_FILE_SIZE to the server\'s current max upload size in bytes -->';
647
+
648
+ $registerFilterArray2['name1'] = '<p class="registerNameHeading"><strong>'. __('Name', 'profilebuilder') .'</strong></p>';
649
+ $registerFilterArray2['name1'] = apply_filters('wppb_register_content_name1', $registerFilterArray2['name1']);
650
+
651
+ if ($wppb_defaultOptions['username'] == 'show'){
652
+ $errorMark = '';
653
+ if ($wppb_defaultOptions['usernameRequired'] == 'yes'){
654
+ $errorMark = '<font color="red" title="This field is required for registration.">*</font>';
655
+ if (isset($_POST['user_name'])){
656
+ if (trim($_POST['user_name']) == ''){
657
+ $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)."/>';
658
+ $errorVar = ' errorHolder';
659
+ }
660
+ }
661
+ }
662
+
663
+ $localVar = '';
664
+ if (isset($_POST['user_name']))
665
+ $localVar = $_POST['user_name'];
666
+ $registerFilterArray2['name2'] = '
667
+ <p class="form-username'.$errorVar.'">
668
+ <label for="user_name">'. __('Username', 'profilebuilder') .$errorMark.'</label>
669
+ <input class="text-input" name="user_name" type="text" id="user_name" value="'.trim($localVar).'" />
670
+ </p><!-- .form-username -->';
671
+ $registerFilterArray2['name2'] = apply_filters('wppb_register_content_name2', $registerFilterArray2['name2']);
672
+ }
673
+
674
+ if ($wppb_defaultOptions['firstname'] == 'show'){
675
+ $errorVar = '';
676
+ $errorMark = '';
677
+ if ($wppb_defaultOptions['firstnameRequired'] == 'yes'){
678
+ $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
679
+ if (isset($_POST['first_name'])){
680
+ if (trim($_POST['first_name']) == ''){
681
+ $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)."/>';
682
+ $errorVar = ' errorHolder';
683
+ }
684
+ }
685
+ }
686
+
687
+ $localVar = '';
688
+ if (isset($_POST['first_name']))
689
+ $localVar = $_POST['first_name'];
690
+ $registerFilterArray2['name3'] = '
691
+ <p class="first_name'.$errorVar.'">
692
+ <label for="first_name">'. __('First Name', 'profilebuilder') .$errorMark.'</label>
693
+ <input class="text-input" name="first_name" type="text" id="first_name" value="'.trim($localVar).'" />
694
+ </p><!-- .first_name -->';
695
+ $registerFilterArray2['name3'] = apply_filters('wppb_register_content_name3', $registerFilterArray2['name3']);
696
+ }
697
+
698
+ if ($wppb_defaultOptions['lastname'] == 'show'){
699
+ $errorVar = '';
700
+ $errorMark = '';
701
+ if ($wppb_defaultOptions['lastnameRequired'] == 'yes'){
702
+ $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
703
+ if (isset($_POST['last_name'])){
704
+ if (trim($_POST['last_name']) == ''){
705
+ $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)."/>';
706
+ $errorVar = ' errorHolder';
707
+ }
708
+ }
709
+ }
710
+
711
+ $localVar = '';
712
+ if (isset($_POST['last_name']))
713
+ $localVar = $_POST['last_name'];
714
+ $registerFilterArray2['name4'] = '
715
+ <p class="last_name'.$errorVar.'">
716
+ <label for="last_name">'. __('Last Name', 'profilebuilder') .$errorMark.'</label>
717
+ <input class="text-input" name="last_name" type="text" id="last_name" value="'.trim($localVar).'" />
718
+ </p><!-- .last_name -->';
719
+ $registerFilterArray2['name4'] = apply_filters('wppb_register_content_name4', $registerFilterArray2['name4']);
720
+ }
721
+
722
+ if ($wppb_defaultOptions['nickname'] == 'show'){
723
+ $errorVar = '';
724
+ $errorMark = '';
725
+ if ($wppb_defaultOptions['nicknameRequired'] == 'yes'){
726
+ $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
727
+ if (isset($_POST['nickname'])){
728
+ if (trim($_POST['nickname']) == ''){
729
+ $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)."/>';
730
+ $errorVar = ' errorHolder';
731
+ }
732
+ }
733
+ }
734
+
735
+ $localVar = '';
736
+ if (isset($_POST['nickname']))
737
+ $localVar = $_POST['nickname'];
738
+ $registerFilterArray2['name5'] = '
739
+ <p class="nickname'.$errorVar.'">
740
+ <label for="nickname">'. __('Nickname', 'profilebuilder') .$errorMark.'</label>
741
+ <input class="text-input" name="nickname" type="text" id="nickname" value="'.trim($localVar).'" />
742
+ </p><!-- .nickname -->';
743
+ $registerFilterArray2['name5'] = apply_filters('wppb_register_content_name5', $registerFilterArray2['name5']);
744
+ }
745
+
746
+ $registerFilterArray2['info1'] = '<p class="registerContactInfoHeading"><strong>'. __('Contact Info', 'profilebuilder') .'</strong></p>';
747
+ $registerFilterArray2['info1'] = apply_filters('wppb_register_content_info1', $registerFilterArray2['info1']);
748
+
749
+ if ($wppb_defaultOptions['email'] == 'show'){
750
+ $errorVar = '';
751
+ $errorMark = '';
752
+ if ($wppb_defaultOptions['emailRequired'] == 'yes'){
753
+ $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
754
+ if (isset($_POST['email'])){
755
+ if (trim($_POST['email']) == ''){
756
+ $errorMark = '<img src="'.WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field is required for registration."/>';
757
+ $errorVar = ' errorHolder';
758
+ }
759
+ }
760
+ }
761
+
762
+ $localVar = '';
763
+ if (isset($_POST['email']))
764
+ $localVar = $_POST['email'];
765
+ $registerFilterArray2['info2'] = '
766
+ <p class="form-email'.$errorVar.'">
767
+ <label for="email">'. __('E-mail', 'profilebuilder') .$errorMark.'</label>
768
+ <input class="text-input" name="email" type="text" id="email" value="'.trim($localVar).'" />
769
+ </p><!-- .form-email -->';
770
+ $registerFilterArray2['info2'] = apply_filters('wppb_register_content_info2', $registerFilterArray2['info2']);
771
+ }
772
+
773
+ if ($wppb_defaultOptions['website'] == 'show'){
774
+ $errorVar = '';
775
+ $errorMark = '';
776
+ if ($wppb_defaultOptions['websiteRequired'] == 'yes'){
777
+ $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
778
+ if (isset($_POST['website'])){
779
+ if (trim($_POST['website']) == ''){
780
+ $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)."/>';
781
+ $errorVar = ' errorHolder';
782
+ }
783
+ }
784
+ }
785
+
786
+ $localVar = '';
787
+ if (isset($_POST['website']))
788
+ $localVar = $_POST['website'];
789
+ $registerFilterArray2['info3'] = '
790
+ <p class="form-website'.$errorVar.'">
791
+ <label for="website">'. __('Website', 'profilebuilder') .$errorMark.'</label>
792
+ <input class="text-input" name="website" type="text" id="website" value="'.trim($localVar).'" />
793
+ </p><!-- .form-website -->';
794
+ $registerFilterArray2['info3'] = apply_filters('wppb_register_content_info3', $registerFilterArray2['info3']);
795
+ }
796
+
797
+ if ($wppb_defaultOptions['aim'] == 'show'){
798
+ $errorVar = '';
799
+ $errorMark = '';
800
+ if ($wppb_defaultOptions['aimRequired'] == 'yes'){
801
+ $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
802
+ if (isset($_POST['aim'])){
803
+ if (trim($_POST['aim']) == ''){
804
+ $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)."/>';
805
+ $errorVar = ' errorHolder';
806
+ }
807
+ }
808
+ }
809
+
810
+ $localVar = '';
811
+ if (isset($_POST['aim']))
812
+ $localVar = $_POST['aim'];
813
+ $registerFilterArray2['info4'] = '
814
+ <p class="form-aim'.$errorVar.'">
815
+ <label for="aim">'. __('AIM', 'profilebuilder') .$errorMark.'</label>
816
+ <input class="text-input" name="aim" type="text" id="aim" value="'.trim($localVar).'" />
817
+ </p><!-- .form-aim -->';
818
+ $registerFilterArray2['info4'] = apply_filters('wppb_register_content_info4', $registerFilterArray2['info4']);
819
+ }
820
+
821
+ if ($wppb_defaultOptions['yahoo'] == 'show'){
822
+ $errorVar = '';
823
+ $errorMark = '';
824
+ if ($wppb_defaultOptions['yahooRequired'] == 'yes'){
825
+ $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
826
+ if (isset($_POST['yim'])){
827
+ if (trim($_POST['yim']) == ''){
828
+ $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)."/>';
829
+ $errorVar = ' errorHolder';
830
+ }
831
+ }
832
+ }
833
+
834
+ $localVar = '';
835
+ if (isset($_POST['yim']))
836
+ $localVar = $_POST['yim'];
837
+ $registerFilterArray2['info5'] = '
838
+ <p class="form-yim'.$errorVar.'">
839
+ <label for="yim">'. __('Yahoo IM', 'profilebuilder') .$errorMark.'</label>
840
+ <input class="text-input" name="yim" type="text" id="yim" value="'.trim($localVar).'" />
841
+ </p><!-- .form-yim -->';
842
+ $registerFilterArray2['info5'] = apply_filters('wppb_register_content_info5', $registerFilterArray2['info5']);
843
+ }
844
+
845
+ if ($wppb_defaultOptions['jabber'] == 'show'){
846
+ $errorVar = '';
847
+ $errorMark = '';
848
+ if ($wppb_defaultOptions['jabberRequired'] == 'yes'){
849
+ $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
850
+ if (isset($_POST['jabber'])){
851
+ if (trim($_POST['jabber']) == ''){
852
+ $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)."/>';
853
+ $errorVar = ' errorHolder';
854
+ }
855
+ }
856
+ }
857
+
858
+ $localVar = '';
859
+ if (isset($_POST['jabber']))
860
+ $localVar = $_POST['jabber'];
861
+ $registerFilterArray2['info6'] = '
862
+ <p class="form-jabber'.$errorVar.'">
863
+ <label for="jabber">'. __('Jabber / Google Talk', 'profilebuilder') .$errorMark.'</label>
864
+ <input class="text-input" name="jabber" type="text" id="jabber" value="'.trim($localVar).'" />
865
+ </p><!-- .form-jabber -->';
866
+ $registerFilterArray2['info6'] = apply_filters('wppb_register_content_info6', $registerFilterArray2['info6']);
867
+ }
868
+
869
+ $registerFilterArray2['ay1'] = '<p class="registerAboutYourselfHeader"><strong>'. __('About Yourself', 'profilebuilder') .'</strong></p>';
870
+ $registerFilterArray2['ay1'] = apply_filters('wppb_register_content_about_yourself1', $registerFilterArray2['ay1']);
871
+
872
+ if ($wppb_defaultOptions['bio'] == 'show'){
873
+ $errorVar = '';
874
+ $errorMark = '';
875
+ if ($wppb_defaultOptions['bioRequired'] == 'yes'){
876
+ $errorMark = '<font color="red" title="This field is marked as required by the administrator.">*</font>';
877
+ if (isset($_POST['description'])){
878
+ if (trim($_POST['description']) == ''){
879
+ $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)."/>';
880
+ $errorVar = ' errorHolder';
881
+ }
882
+ }
883
+ }
884
+
885
+ $localVar = '';
886
+ if (isset($_POST['description']))
887
+ $localVar = $_POST['description'];
888
+ $registerFilterArray2['ay2'] = '
889
+ <p class="form-description'.$errorVar.'">
890
+ <label for="description">'. __('Biographical Info', 'profilebuilder') .$errorMark.'</label>
891
+ <textarea class="text-input" name="description" id="description" rows="5" cols="30">'.trim($localVar).'</textarea>
892
+ </p><!-- .form-description -->';
893
+ $registerFilterArray2['ay2'] = apply_filters('wppb_register_content_about_yourself2', $registerFilterArray2['ay2']);
894
+ }
895
+
896
+ if ($wppb_defaultOptions['password'] == 'show'){
897
+ $errorMark = '';
898
+ if ($wppb_defaultOptions['passwordRequired'] == 'yes'){
899
+ $errorMark = '<font color="red" title="This field is required for registration.">*</font>';
900
+ $errorMark2 = '<font color="red" title="This field is required for registration.">*</font>';
901
+ if ((trim($_POST['passw1']) == '') && isset ($_POST['passw1'])){
902
+ $errorMark = '<img src="'.WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field is required for registration."/>';
903
+ $errorVar = ' errorHolder';
904
+ }
905
+ if ((trim($_POST['passw2']) == '') && isset ($_POST['passw2'])){
906
+ $errorMark2 = '<img src="'.WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field is required for registration."/>';
907
+ $errorVar2 = ' errorHolder';
908
+ }
909
+ }
910
+
911
+ $localVar1 = '';
912
+ if (isset($_POST['passw1']))
913
+ $localVar1 = $_POST['passw1'];
914
+ $localVar2 = '';
915
+ if (isset($_POST['passw2']))
916
+ $localVar2 = $_POST['passw2'];
917
+ $registerFilterArray2['ay3'] = '
918
+ <p class="form-password'.$errorVar.'">
919
+ <label for="pass1">'. __('Password', 'profilebuilder') .$errorMark.'</label>
920
+ <input class="text-input" name="passw1" type="password" id="pass1" value="'.trim($localVar1).'" />
921
+ </p><!-- .form-password -->
922
+
923
+ <p class="form-password'.$errorVar2.'">
924
+ <label for="pass2">'. __('Repeat Password', 'profilebuilder') .$errorMark2.'</label>
925
+ <input class="text-input" name="passw2" type="password" id="pass2" value="'.trim($localVar2).'" />
926
+ </p><!-- .form-password -->';
927
+ $registerFilterArray2['ay3'] = apply_filters('wppb_register_content_about_yourself3', $registerFilterArray2['ay3']);
928
+ }
929
+
930
+ $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/';
931
+ if (file_exists ( $wppb_premium.'extra.fields.php' )){
932
+ require_once($wppb_premium.'extra.fields.php');
933
+
934
+ //register_user_extra_fields($error, $_POST, $extraFieldsErrorHolder);
935
+ $page = 'register';
936
+ $returnedValue = wppb_extra_fields($current_user->id, $extraFieldsErrorHolder, $editProfileFilterArray, $page, $error, $_POST);
937
+
938
+ //copy over extra fields to the rest of the fieldso on the edit profile
939
+ foreach($returnedValue as $key => $value)
940
+ $registerFilterArray2[$key] = $value;
941
+ }
942
+
943
+ /* additional filter, just in case it is needed (for instance for a recaptcha form) */
944
+ $registerFilterArray2['extraRegistrationFilter'] = '';
945
+ $registerFilterArray2['extraRegistrationFilter'] = apply_filters('extraRegistrationField', $registerFilterArray2['extraRegistrationFilter']);
946
+ /* END additional filter, just in case it is needed (for instance for a recaptcha form) */
947
+
948
+ if (isset($_POST['send_credentials_via_email']))
949
+ $checkedVar = ' checked';
950
+ else $checkedVar = '';
951
+ $registerFilterArray2['confirmationEmailForm'] = '
952
+ <p class="send-confirmation-email">
953
+ <label for="send-confirmation-email">
954
+ <input id="send_credentials_via_email" type="checkbox" name="send_credentials_via_email" value="sending"'. $checkedVar .'/>
955
+ <span class="wppb-description-delimiter"> '. __('Send these credentials via email.', 'profilebuilder') .'</span>
956
+ </label>
957
+ </p><!-- .send-confirmation-email -->';
958
+ $registerFilterArray2['confirmationEmailForm'] = apply_filters('wppb_register_confirmation_email_form', $registerFilterArray2['confirmationEmailForm']);
959
+
960
+
961
+ $registerFilterArray2 = apply_filters('wppb_register', $registerFilterArray2);
962
+ foreach ($registerFilterArray2 as $key => $value)
963
+ echo $value;
964
+ ?>
965
+
966
+ <p class="form-submit">
967
+ <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'); ?>" />
968
+ <input name="action" type="hidden" id="action" value="adduser" />
969
+ </p><!-- .form-submit -->
970
+ <?php
971
+ wp_nonce_field('verify_true_registration','register_nonce_field');
972
+ ?>
973
+ </form><!-- #adduser -->
974
+
975
+ <?php
976
+ endif;
977
+ endif;
978
+
979
+ /* use this action hook to add extra content after the register form. */
980
+ do_action( 'wppb_after_register_fields' );
981
+ ?>
982
+
983
+ </div>
984
+ <?php
985
+ $output = ob_get_contents();
986
+ ob_end_clean();
987
+
988
+ return $output;
989
+ }
990
  ?>
functions/functions.load.php CHANGED
@@ -1,185 +1,185 @@
1
- <?php if (!defined('ProfileBuilderVersion')) exit('No direct script access allowed');
2
- /*
3
- Original Plugin Name: OptionTree
4
- Original Plugin URI: http://wp.envato.com
5
- Original Author: Derek Herman
6
- Original Author URI: http://valendesigns.com
7
- */
8
-
9
- /**
10
- * Functions Load
11
- *
12
- */
13
- /* whitelist options, you can add more register_settings changing the second parameter */
14
-
15
- function wppb_register_settings() {
16
- $premiumPresent = wppb_plugin_dir . '/premium/premium.php';
17
- $addonPresent = wppb_plugin_dir . '/premium/addon/addon.php';
18
-
19
- register_setting( 'wppb_option_group', 'wppb_default_settings' );
20
- register_setting( 'wppb_default_style', 'wppb_default_style' );
21
- register_setting( 'wppb_display_admin_settings', 'wppb_display_admin_settings' );
22
- if (file_exists($premiumPresent)){
23
- register_setting( 'wppb_profile_builder_pro_serial', 'wppb_profile_builder_pro_serial' );
24
- }
25
- if (file_exists($addonPresent)){
26
- register_setting( 'wppb_premium_addon_settings', 'wppb_premium_addon_settings' );
27
- register_setting( 'customRedirectSettings', 'customRedirectSettings' );
28
- register_setting( 'userListingSettings', 'userListingSettings' );
29
- }
30
-
31
-
32
- }
33
-
34
-
35
- function wppb_add_plugin_stylesheet() {
36
- $wppb_showDefaultCss = get_option('wppb_default_style');
37
- $styleUrl_default = wppb_plugin_url . '/assets/css/front.end.css';
38
- $styleUrl_white = wppb_plugin_url . '/premium/assets/css/front.end.white.css';
39
- $styleUrl_black = wppb_plugin_url . '/premium/assets/css/front.end.black.css';
40
- $styleFile_default = wppb_plugin_dir . '/assets/css/front.end.css';
41
- $styleFile_white = wppb_plugin_dir . '/premium/assets/css/front.end.white.css';
42
- $styleFile_black = wppb_plugin_dir . '/premium/assets/css/front.end.black.css';
43
- if ( (file_exists($styleFile_default)) && ($wppb_showDefaultCss == 'yes') ) {
44
- wp_register_style('wppb_stylesheet', $styleUrl_default);
45
- wp_enqueue_style( 'wppb_stylesheet');
46
- }elseif ( (file_exists($styleFile_white)) && ($wppb_showDefaultCss == 'white') ) {
47
- wp_register_style('wppb_stylesheet', $styleUrl_white);
48
- wp_enqueue_style( 'wppb_stylesheet');
49
- }elseif ( (file_exists($styleFile_black)) && ($wppb_showDefaultCss == 'black') ) {
50
- wp_register_style('wppb_stylesheet', $styleUrl_black);
51
- wp_enqueue_style( 'wppb_stylesheet');
52
- }
53
- }
54
-
55
-
56
- function wppb_show_admin_bar($content){
57
- global $current_user;
58
- $admintSettingsPresent = get_option('wppb_display_admin_settings','not_found');
59
- if ($admintSettingsPresent != 'not_found'){
60
- $wppb_showAdminBar = get_option('wppb_display_admin_settings');
61
- if ($current_user->ID != 0){
62
- $userRole = ($current_user->data->wp_capabilities);
63
- if ($userRole != NULL){
64
- $currentRole = key($userRole);
65
- $getSettings = $wppb_showAdminBar[$currentRole];
66
- if ($getSettings == 'show')
67
- return true;
68
- elseif ($getSettings == 'hide')
69
- return false;
70
- }
71
- }
72
- }
73
- else
74
- return true;
75
- }
76
-
77
- if(!function_exists('wppb_curpageurl')){
78
- function wppb_curpageurl() {
79
- $pageURL = 'http';
80
- if ((isset($_SERVER["HTTPS"])) && ($_SERVER["HTTPS"] == "on")) {
81
- $pageURL .= "s";
82
- }
83
- $pageURL .= "://";
84
- if ($_SERVER["SERVER_PORT"] != "80") {
85
- $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
86
- } else {
87
- $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
88
- }
89
- return $pageURL;
90
- }
91
- }
92
-
93
-
94
-
95
- if ( is_admin() ){
96
- /* include the css for the datepicker */
97
- $wppb_premiumDatepicker = wppb_plugin_dir . '/premium/assets/css/';
98
- if (file_exists ( $wppb_premiumDatepicker.'datepicker.style.css' ))
99
- wp_enqueue_style( 'profile-builder-admin-datepicker-style', wppb_plugin_url.'/premium/assets/css/datepicker.style.css', false, ProfileBuilderVersion);
100
-
101
-
102
-
103
- /* register the settings for the menu only display sidebar menu for a user with a certain capability, in this case only the "admin" */
104
- add_action('admin_init', 'wppb_register_settings');
105
-
106
- $wppb_premiumAdmin = wppb_plugin_dir . '/premium/functions/';
107
- if (file_exists ( $wppb_premiumAdmin.'premium.functions.load.php' )){
108
- include_once($wppb_premiumAdmin.'premium.functions.load.php');
109
-
110
- /* check whether a delete attachment has been requested */
111
- add_action('admin_init', 'wppb_deleteAttachment');
112
-
113
- /* check whether a delete avatar has been requested */
114
- add_action('admin_init', 'wppb_deleteAvatar');
115
-
116
- }
117
-
118
-
119
- /* display the same extra profile fields in the admin panel also */
120
- $wppb_premium = wppb_plugin_dir . '/premium/functions/';
121
- if (file_exists ( $wppb_premium.'extra.fields.php' )){
122
- include( $wppb_premium.'extra.fields.php' );
123
- add_action( 'show_user_profile', 'display_profile_extra_fields', 10 );
124
- add_action( 'edit_user_profile', 'display_profile_extra_fields', 10 );
125
- add_action( 'personal_options_update', 'save_extra_profile_fields', 10 );
126
- add_action( 'edit_user_profile_update', 'save_extra_profile_fields', 10 );
127
-
128
- /* check to see if the inserted serial number is valid or not; purely for visual needs */
129
- add_action('admin_init', 'wppb_check_serial_number');
130
- }
131
-
132
- }
133
- else if ( !is_admin() ){
134
- /* include the stylesheet */
135
- add_action('wp_print_styles', 'wppb_add_plugin_stylesheet');
136
-
137
- $wppb_plugin = wppb_plugin_dir . '/';
138
-
139
- /* include the menu file for the profile informations */
140
- include_once($wppb_plugin.'front-end/wppb.edit.profile.php');
141
- add_shortcode('wppb-edit-profile', 'wppb_front_end_profile_info');
142
-
143
- /*include the menu file for the login screen */
144
- include_once($wppb_plugin.'front-end/wppb.login.php');
145
- add_shortcode('wppb-login', 'wppb_front_end_login');
146
-
147
- /* include the menu file for the register screen */
148
- include_once($wppb_plugin.'front-end/wppb.register.php');
149
- add_shortcode('wppb-register', 'wppb_front_end_register');
150
-
151
- /* include the menu file for the recover password screen */
152
- include_once($wppb_plugin.'front-end/wppb.recover.password.php');
153
- add_shortcode('wppb-recover-password', 'wppb_front_end_password_recovery');
154
-
155
- /* set the front-end admin bar to show/hide */
156
- add_filter( 'show_admin_bar' , 'wppb_show_admin_bar');
157
-
158
- /* Shortcodes used for the widget area. Just uncomment whichever you need */
159
- add_filter('widget_text', 'do_shortcode', 11);
160
-
161
- /* check to see if the premium functions are present */
162
- $wppb_premiumAdmin = wppb_plugin_dir . '/premium/functions/';
163
- if (file_exists ( $wppb_premiumAdmin.'premium.functions.load.php' )){
164
-
165
- include_once($wppb_premiumAdmin.'premium.functions.load.php');
166
-
167
- /* filter to set current users custom avatar */
168
- add_filter('get_avatar', 'wppb_changeDefaultAvatar', 21, 5);
169
-
170
- /* check if there is a need to resize the current avatar image for all the users*/
171
- add_action('init', 'wppb_resize_avatar');
172
- }
173
-
174
- $wppb_premiumAddon = wppb_plugin_dir . '/premium/addon/';
175
- if (file_exists ( $wppb_premiumAddon.'addon.functions.php' )){
176
- //include the file containing the addon functions
177
- include_once($wppb_premiumAddon.'addon.functions.php');
178
-
179
- $wppb_addonOptions = get_option('wppb_premium_addon_settings');
180
- if ($wppb_addonOptions['userListing'] == 'show'){
181
- //add shortcode for the user-listing functionality
182
- add_shortcode('wppb-list-users', 'wppb_list_all_users');
183
- }
184
- }
185
  }
1
+ <?php if (!defined('PROFILE_BUILDER_VERSION')) exit('No direct script access allowed');
2
+ /*
3
+ Original Plugin Name: OptionTree
4
+ Original Plugin URI: http://wp.envato.com
5
+ Original Author: Derek Herman
6
+ Original Author URI: http://valendesigns.com
7
+ */
8
+
9
+ /**
10
+ * Functions Load
11
+ *
12
+ */
13
+ /* whitelist options, you can add more register_settings changing the second parameter */
14
+
15
+ function wppb_register_settings() {
16
+ $premiumPresent = WPPB_PLUGIN_DIR . '/premium/premium.php';
17
+ $addonPresent = WPPB_PLUGIN_DIR . '/premium/addon/addon.php';
18
+
19
+ register_setting( 'wppb_option_group', 'wppb_default_settings' );
20
+ register_setting( 'wppb_default_style', 'wppb_default_style' );
21
+ register_setting( 'wppb_display_admin_settings', 'wppb_display_admin_settings' );
22
+ if (file_exists($premiumPresent)){
23
+ register_setting( 'wppb_profile_builder_pro_serial', 'wppb_profile_builder_pro_serial' );
24
+ }
25
+ if (file_exists($addonPresent)){
26
+ register_setting( 'wppb_premium_addon_settings', 'wppb_premium_addon_settings' );
27
+ register_setting( 'customRedirectSettings', 'customRedirectSettings' );
28
+ register_setting( 'userListingSettings', 'userListingSettings' );
29
+ }
30
+
31
+
32
+ }
33
+
34
+ $wppb_premiumAdmin = WPPB_PLUGIN_DIR . '/premium/functions/';
35
+ if (file_exists ( $wppb_premiumAdmin.'premium.functions.load.php' ))
36
+ include_once($wppb_premiumAdmin.'premium.functions.load.php');
37
+
38
+ function wppb_add_plugin_stylesheet() {
39
+ $wppb_showDefaultCss = get_option('wppb_default_style');
40
+ $styleUrl_default = WPPB_PLUGIN_URL . '/assets/css/front.end.css';
41
+ $styleUrl_white = WPPB_PLUGIN_URL . '/premium/assets/css/front.end.white.css';
42
+ $styleUrl_black = WPPB_PLUGIN_URL . '/premium/assets/css/front.end.black.css';
43
+ $styleFile_default = WPPB_PLUGIN_DIR . '/assets/css/front.end.css';
44
+ $styleFile_white = WPPB_PLUGIN_DIR . '/premium/assets/css/front.end.white.css';
45
+ $styleFile_black = WPPB_PLUGIN_DIR . '/premium/assets/css/front.end.black.css';
46
+ if ( (file_exists($styleFile_default)) && ($wppb_showDefaultCss == 'yes') ) {
47
+ wp_register_style('wppb_stylesheet', $styleUrl_default);
48
+ wp_enqueue_style( 'wppb_stylesheet');
49
+ }elseif ( (file_exists($styleFile_white)) && ($wppb_showDefaultCss == 'white') ) {
50
+ wp_register_style('wppb_stylesheet', $styleUrl_white);
51
+ wp_enqueue_style( 'wppb_stylesheet');
52
+ }elseif ( (file_exists($styleFile_black)) && ($wppb_showDefaultCss == 'black') ) {
53
+ wp_register_style('wppb_stylesheet', $styleUrl_black);
54
+ wp_enqueue_style( 'wppb_stylesheet');
55
+ }
56
+ }
57
+
58
+
59
+ function wppb_show_admin_bar($content){
60
+ global $current_user;
61
+ global $wpdb;
62
+ $admintSettingsPresent = get_option('wppb_display_admin_settings','not_found');
63
+
64
+ if ($admintSettingsPresent != 'not_found'){
65
+ if ($current_user->ID != 0){
66
+ $capabilityName = $wpdb->prefix.'capabilities';
67
+ $userRole = ($current_user->data->$capabilityName);
68
+ if ($userRole != NULL){
69
+ $currentRole = key($userRole);
70
+ $getSettings = $admintSettingsPresent[$currentRole];
71
+ if ($getSettings == 'show')
72
+ return true;
73
+ elseif ($getSettings == 'hide')
74
+ return false;
75
+ }elseif ($userRole == NULL){ // this is for the WP v.3.3
76
+ $userRole = ($current_user->roles[0]);
77
+ if ($userRole != NULL){
78
+ $getSettings = $admintSettingsPresent[$userRole];
79
+ if ($getSettings == 'show')
80
+ return true;
81
+ elseif ($getSettings == 'hide')
82
+ return false;
83
+ }
84
+ }else
85
+ return true;
86
+ }
87
+ }
88
+ else
89
+ return true;
90
+ }
91
+
92
+ if(!function_exists('wppb_curpageurl')){
93
+ function wppb_curpageurl() {
94
+ $pageURL = 'http';
95
+ if ((isset($_SERVER["HTTPS"])) && ($_SERVER["HTTPS"] == "on")) {
96
+ $pageURL .= "s";
97
+ }
98
+ $pageURL .= "://";
99
+ if ($_SERVER["SERVER_PORT"] != "80") {
100
+ $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
101
+ } else {
102
+ $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
103
+ }
104
+ return $pageURL;
105
+ }
106
+ }
107
+
108
+
109
+
110
+ if ( is_admin() ){
111
+ /* include the css for the datepicker */
112
+ $wppb_premiumDatepicker = WPPB_PLUGIN_DIR . '/premium/assets/css/';
113
+ if (file_exists ( $wppb_premiumDatepicker.'datepicker.style.css' ))
114
+ wp_enqueue_style( 'profile-builder-admin-datepicker-style', WPPB_PLUGIN_URL.'/premium/assets/css/datepicker.style.css', false, PROFILE_BUILDER_VERSION);
115
+
116
+
117
+
118
+ /* register the settings for the menu only display sidebar menu for a user with a certain capability, in this case only the "admin" */
119
+ add_action('admin_init', 'wppb_register_settings');
120
+
121
+
122
+ /* display the same extra profile fields in the admin panel also */
123
+ $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/';
124
+ if (file_exists ( $wppb_premium.'extra.fields.php' )){
125
+ include( $wppb_premium.'extra.fields.php' );
126
+ add_action( 'show_user_profile', 'display_profile_extra_fields_in_admin', 10 );
127
+ add_action( 'edit_user_profile', 'display_profile_extra_fields_in_admin', 10 );
128
+ add_action( 'personal_options_update', 'save_profile_extra_fields_in_admin', 10 );
129
+ add_action( 'edit_user_profile_update', 'save_profile_extra_fields_in_admin', 10 );
130
+
131
+ /* check to see if the inserted serial number is valid or not; purely for visual needs */
132
+ add_action('admin_init', 'wppb_check_serial_number');
133
+ }
134
+
135
+ }
136
+ else if ( !is_admin() ){
137
+ /* include the stylesheet */
138
+ add_action('wp_print_styles', 'wppb_add_plugin_stylesheet');
139
+
140
+ $wppb_plugin = WPPB_PLUGIN_DIR . '/';
141
+
142
+ /* include the menu file for the profile informations */
143
+ include_once($wppb_plugin.'front-end/wppb.edit.profile.php');
144
+ add_shortcode('wppb-edit-profile', 'wppb_front_end_profile_info');
145
+
146
+ /*include the menu file for the login screen */
147
+ include_once($wppb_plugin.'front-end/wppb.login.php');
148
+ add_shortcode('wppb-login', 'wppb_front_end_login');
149
+
150
+ /* include the menu file for the register screen */
151
+ include_once($wppb_plugin.'front-end/wppb.register.php');
152
+ add_shortcode('wppb-register', 'wppb_front_end_register');
153
+
154
+ /* include the menu file for the recover password screen */
155
+ include_once($wppb_plugin.'front-end/wppb.recover.password.php');
156
+ add_shortcode('wppb-recover-password', 'wppb_front_end_password_recovery');
157
+
158
+ /* set the front-end admin bar to show/hide */
159
+ add_filter( 'show_admin_bar' , 'wppb_show_admin_bar');
160
+
161
+ /* Shortcodes used for the widget area. Just uncomment whichever you need */
162
+ add_filter('widget_text', 'do_shortcode', 11);
163
+
164
+ /* check to see if the premium functions are present */
165
+ $wppb_premiumAdmin = WPPB_PLUGIN_DIR . '/premium/functions/';
166
+ if (file_exists ( $wppb_premiumAdmin.'premium.functions.load.php' )){
167
+
168
+ include_once($wppb_premiumAdmin.'premium.functions.load.php');
169
+
170
+ /* filter to set current users custom avatar */
171
+ add_filter('get_avatar', 'wppb_changeDefaultAvatar', 21, 5);
172
+ }
173
+
174
+ $wppb_premiumAddon = WPPB_PLUGIN_DIR . '/premium/addon/';
175
+ if (file_exists ( $wppb_premiumAddon.'addon.functions.php' )){
176
+ //include the file containing the addon functions
177
+ include_once($wppb_premiumAddon.'addon.functions.php');
178
+
179
+ $wppb_addonOptions = get_option('wppb_premium_addon_settings');
180
+ if ($wppb_addonOptions['userListing'] == 'show'){
181
+ //add shortcode for the user-listing functionality
182
+ add_shortcode('wppb-list-users', 'wppb_list_all_users');
183
+ }
184
+ }
185
  }
index.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Profile Builder
4
  Plugin URI: http://www.cozmoslabs.com/2011/04/12/wordpress-profile-builder-a-front-end-user-registration-login-and-edit-profile-plugin/
5
  Description: Login, registration and edit profile shortcodes for the front-end. Also you can chose what fields should be displayed or add new (custom) ones both in the front-end and in the dashboard.
6
- Version: 1.1.14
7
  Author: Reflection Media, Barina Gabriel
8
  Author URI: http://www.reflectionmedia.ro
9
  License: GPL2
@@ -54,7 +54,7 @@ function return_bytes($val) {
54
  }
55
 
56
 
57
- define( 'ProfileBuilderVersion', '1.1.14' );
58
  define( 'wppb_plugin_dir', WP_PLUGIN_DIR . '/' . dirname( plugin_basename( __FILE__ ) ) );
59
  define( 'wppb_plugin_url', WP_PLUGIN_URL . '/' . dirname( plugin_basename( __FILE__ ) ) );
60
  define( 'ServerMaxUploadSizeByte', return_bytes( ini_get( 'upload_max_filesize') ) );
3
  Plugin Name: Profile Builder
4
  Plugin URI: http://www.cozmoslabs.com/2011/04/12/wordpress-profile-builder-a-front-end-user-registration-login-and-edit-profile-plugin/
5
  Description: Login, registration and edit profile shortcodes for the front-end. Also you can chose what fields should be displayed or add new (custom) ones both in the front-end and in the dashboard.
6
+ Version: 1.1.16
7
  Author: Reflection Media, Barina Gabriel
8
  Author URI: http://www.reflectionmedia.ro
9
  License: GPL2
54
  }
55
 
56
 
57
+ define( 'ProfileBuilderVersion', '1.1.16' );
58
  define( 'wppb_plugin_dir', WP_PLUGIN_DIR . '/' . dirname( plugin_basename( __FILE__ ) ) );
59
  define( 'wppb_plugin_url', WP_PLUGIN_URL . '/' . dirname( plugin_basename( __FILE__ ) ) );
60
  define( 'ServerMaxUploadSizeByte', return_bytes( ini_get( 'upload_max_filesize') ) );
readme.txt CHANGED
@@ -7,7 +7,7 @@ custom registration, custom registration form, custom registration page, extra u
7
  front-end register, front-end registration, frontend edit profile, edit profile
8
  Requires at least: 3.1
9
  Tested up to: 3.3
10
- Stable tag: 1.1.14
11
 
12
  Simple to use profile plugin allowing front-end login, registration and edit profile by using shortcodes.
13
 
@@ -89,6 +89,12 @@ This plugin only adds/removes fields in the front-end. The default information-f
89
  7. Logged in Page: screenshot7.jpg
90
 
91
  == Changelog ==
 
 
 
 
 
 
92
  = 1.1.14 =
93
  Compatibility fix for WP version 3.3
94
 
7
  front-end register, front-end registration, frontend edit profile, edit profile
8
  Requires at least: 3.1
9
  Tested up to: 3.3
10
+ Stable tag: 1.1.16
11
 
12
  Simple to use profile plugin allowing front-end login, registration and edit profile by using shortcodes.
13
 
89
  7. Logged in Page: screenshot7.jpg
90
 
91
  == Changelog ==
92
+ = 1.1.16 =
93
+ Minor bugfixes.
94
+
95
+ = 1.1.15 =
96
+ Minor changes in the index file.
97
+
98
  = 1.1.14 =
99
  Compatibility fix for WP version 3.3
100