| 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 |
{ |
| 28 |
wp_update_user( array( 'ID' => $current_user->id, 'user_pass' => esc_attr( $_POST['pass1'] ) ) ); |
| 29 |
$changesSaved = 'yes'; |
| 30 |
} else { |
| 31 |
$changesSavedNoMatchingPass = 'yes'; |
| 32 |
} |
| 33 |
}elseif (( empty($_POST['pass1'] ) && !empty( $_POST['pass2'] )) || ( !empty($_POST['pass1'] ) && empty( $_POST['pass2'] )) ) { |
| 34 |
$changesSavedNoPass = 'yes'; |
| 35 |
} |
| 36 |
} |
| 37 |
} |
| 38 |
add_action('init', 'wppb_save_the_password'); |
| 39 |
|
| 40 |
function wppb_front_end_profile_info() { |
| 41 |
|
| 42 |
global $changesSaved; |
| 43 |
global $changesSavedNoMatchingPass; |
| 44 |
global $changesSavedNoPass; |
| 45 |
|
| 46 |
ob_start(); |
| 47 |
get_currentuserinfo(); |
| 48 |
$wppb_defaultOptions = get_option('wppb_default_settings'); |
| 49 |
$changesSavedNoEmail = 'no'; |
| 50 |
$changesSavedNoEmailExist = 'no'; |
| 51 |
$previousError = 'no'; |
| 52 |
$pictureUpload = 'no'; |
| 53 |
$avatarUpload = 'yes'; |
| 54 |
$uploadName = array(); |
| 55 |
$uploadSize = array(); |
| 56 |
|
| 57 |
|
| 58 |
/* Load registration file. */ |
| 59 |
require_once(ABSPATH . WPINC . '/registration.php'); |
| 60 |
/* Get user info. */ |
| 61 |
global $current_user; |
| 62 |
|
| 63 |
/* delete the attachment if set */ |
| 64 |
if (isset($_GET['userID']) && isset($_GET['field'])){ |
| 65 |
update_user_meta( $_GET['userID'], $_GET['field'], ''); |
| 66 |
} |
| 67 |
/* delete the avatar */ |
| 68 |
if (isset($_GET['userID']) && isset($_GET['fieldOriginal']) && isset($_GET['fieldResized'])){ |
| 69 |
update_user_meta( $_GET['userID'], $_GET['fieldOriginal'], ''); |
| 70 |
update_user_meta( $_GET['userID'], $_GET['fieldResized'], ''); |
| 71 |
} |
| 72 |
|
| 73 |
//fallback if the file was largen then post_max_size, case in which no errors can be saved in $_FILES[fileName]['error'] |
| 74 |
if (empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post') { |
| 75 |
echo '<p class="error">'; |
| 76 |
_e('The information size you were trying to submit was larger then '. ServerMaxUploadSizeMega .'b!<br/>', 'profilebuilder'); |
| 77 |
_e('This is usually caused by a large file(s) trying to be uploaded.<br/>', 'profilebuilder'); |
| 78 |
_e('Since it was also larger than '. ServerMaxPostSizeMega .'b no additional information is available.<br/>', 'profilebuilder'); |
| 79 |
echo '</p>'; |
| 80 |
} |
| 81 |
|
| 82 |
/* If profile was saved, update profile. */ |
| 83 |
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'update-user' && wp_verify_nonce($_POST['edit_nonce_field'],'verify_edit_user') ) { |
| 84 |
|
| 85 |
if (email_exists( $_POST['email'] ) != FALSE) |
| 86 |
$thisEmail = email_exists( $_POST['email'] ); |
| 87 |
else $thisEmail = $current_user->id; |
| 88 |
|
| 89 |
if ( !empty( $_POST['email'] ) && is_email( $_POST['email'] )){ // if the user entered a valid email address |
| 90 |
if (($thisEmail == $current_user->id)){ // if the entered email address is not already registered to some other user |
| 91 |
wp_update_user( array( 'ID' => $current_user->id, 'user_email' => esc_attr( $_POST['email'] ))); |
| 92 |
$changesSaved = 'yes'; |
| 93 |
}else{ |
| 94 |
$changesSavedNoEmailExist = 'yes'; |
| 95 |
} |
| 96 |
}else{ |
| 97 |
$changesSavedNoEmail = 'yes'; |
| 98 |
} |
| 99 |
|
| 100 |
|
| 101 |
/* Update user information. */ |
| 102 |
if ($wppb_defaultOptions['firstname'] == 'show'){ |
| 103 |
wp_update_user( array( 'ID' => $current_user->id, 'first_name' => esc_attr( $_POST['first_name'] ))); |
| 104 |
$changesSaved = 'yes'; |
| 105 |
} |
| 106 |
if ($wppb_defaultOptions['lastname'] == 'show'){ |
| 107 |
wp_update_user( array( 'ID' => $current_user->id, 'last_name' => esc_attr( $_POST['last_name'] ))); |
| 108 |
$changesSaved = 'yes'; |
| 109 |
} |
| 110 |
|
| 111 |
if ($wppb_defaultOptions['nickname'] == 'show'){ |
| 112 |
wp_update_user( array( 'ID' => $current_user->id, 'nickname' => esc_attr( $_POST['nickname'] ))); |
| 113 |
$changesSaved = 'yes'; |
| 114 |
} |
| 115 |
|
| 116 |
if ($wppb_defaultOptions['dispname'] == 'show'){ |
| 117 |
wp_update_user( array( 'ID' => $current_user->id, 'display_name' => esc_attr( $_POST['display_name'] ))); |
| 118 |
$changesSaved = 'yes'; |
| 119 |
} |
| 120 |
|
| 121 |
if ($wppb_defaultOptions['website'] == 'show'){ |
| 122 |
$wppbPos = strpos($_POST['website'], 'http://'); |
| 123 |
if($wppbPos !== FALSE){ |
| 124 |
wp_update_user( array( 'ID' => $current_user->id, 'user_url' => esc_attr( $_POST['website'] ))); |
| 125 |
$changesSaved = 'yes'; |
| 126 |
}else{ |
| 127 |
wp_update_user( array( 'ID' => $current_user->id, 'user_url' => 'http://'.esc_attr( $_POST['website'] ))); |
| 128 |
$changesSaved = 'yes'; |
| 129 |
} |
| 130 |
} |
| 131 |
|
| 132 |
if ($wppb_defaultOptions['aim'] == 'show'){ |
| 133 |
update_user_meta( $current_user->id, 'aim', esc_attr( $_POST['aim'] ) ); |
| 134 |
$changesSaved = 'yes'; |
| 135 |
} |
| 136 |
|
| 137 |
if ($wppb_defaultOptions['yahoo'] == 'show'){ |
| 138 |
update_user_meta( $current_user->id, 'yim', esc_attr( $_POST['yim'] ) ); |
| 139 |
$changesSaved = 'yes'; |
| 140 |
} |
| 141 |
|
| 142 |
if ($wppb_defaultOptions['jabber'] == 'show'){ |
| 143 |
update_user_meta( $current_user->id, 'jabber', esc_attr( $_POST['jabber'] ) ); |
| 144 |
$changesSaved = 'yes'; |
| 145 |
} |
| 146 |
|
| 147 |
if ($wppb_defaultOptions['bio'] == 'show'){ |
| 148 |
update_user_meta( $current_user->id, 'description', esc_attr( $_POST['description'] ) ); |
| 149 |
$changesSaved = 'yes'; |
| 150 |
} |
| 151 |
|
| 152 |
/* update the extra profile information */ |
| 153 |
$wppb_premium = wppb_plugin_dir . '/premium/functions/'; |
| 154 |
if (file_exists ( $wppb_premium.'extra.fields.php' )){ |
| 155 |
$wppbFetchArray = get_option('wppb_custom_fields'); |
| 156 |
foreach ( $wppbFetchArray as $key => $value){ |
| 157 |
switch ($value['item_type']) { |
| 158 |
case "input":{ |
| 159 |
update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) ); |
| 160 |
break; |
| 161 |
} |
| 162 |
case "checkbox":{ |
| 163 |
$checkboxOption = ''; |
| 164 |
$checkboxValue = explode(',', $value['item_options']); |
| 165 |
foreach($checkboxValue as $thisValue){ |
| 166 |
$thisValue = str_replace(' ', '#@space@#', $thisValue); //we need to escape the space-codification we sent earlier in the post |
| 167 |
if (isset($_POST[$thisValue.$value['id']])){ |
| 168 |
$localValue = str_replace('#@space@#', ' ', $_POST[$thisValue.$value['id']]); |
| 169 |
$checkboxOption = $checkboxOption.$localValue.','; |
| 170 |
} |
| 171 |
} |
| 172 |
update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $checkboxOption ) ); |
| 173 |
break; |
| 174 |
} |
| 175 |
case "radio":{ |
| 176 |
update_user_meta( $current_user->id, 'custom_field_'.$value['id'], $_POST[$value['item_id'].$value['id']] ); |
| 177 |
break; |
| 178 |
} |
| 179 |
case "select":{ |
| 180 |
update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) ); |
| 181 |
break; |
| 182 |
} |
| 183 |
case "countrySelect":{ |
| 184 |
update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) ); |
| 185 |
break; |
| 186 |
} |
| 187 |
case "timeZone":{ |
| 188 |
update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) ); |
| 189 |
break; |
| 190 |
} |
| 191 |
case "datepicker":{ |
| 192 |
update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) ); |
| 193 |
break; |
| 194 |
} |
| 195 |
case "textarea":{ |
| 196 |
update_user_meta( $current_user->id, 'custom_field_'.$value['id'], esc_attr( $_POST[$value['item_id'].$value['id']] ) ); |
| 197 |
break; |
| 198 |
} |
| 199 |
case "upload":{ |
| 200 |
$uploadedfile = $value['item_type'].$value['id']; |
| 201 |
|
| 202 |
//first we need to verify if we don't try to upload a 0b or 0 length file |
| 203 |
if ( (basename( $_FILES[$uploadedfile]['name']) != '')){ |
| 204 |
|
| 205 |
//second we need to verify if the uploaded file size is less then the set file size in php.ini |
| 206 |
if (($_FILES[$uploadedfile]['size'] < ServerMaxUploadSizeByte) && ($_FILES[$uploadedfile]['size'] !=0)){ |
| 207 |
//we need to prepare the basename of the file, so that ' becomes ` as ' gives an error |
| 208 |
$fileName = basename( $_FILES[$uploadedfile]['name']); |
| 209 |
$finalFileName = ''; |
| 210 |
|
| 211 |
for ($i=0; $i < strlen($fileName); $i++){ |
| 212 |
if ($fileName[$i] == "'") |
| 213 |
$finalFileName .= '`'; |
| 214 |
else $finalFileName .= $fileName[$i]; |
| 215 |
} |
| 216 |
|
| 217 |
//create the target path for uploading |
| 218 |
$target_path = "wp-content/uploads/profile_builder/attachments/"; |
| 219 |
$target_path = $target_path . 'userID_'.$current_user->id.'_attachment_'. $finalFileName; |
| 220 |
|
| 221 |
if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)){ |
| 222 |
$upFile = get_bloginfo('home').'/'.$target_path; |
| 223 |
update_user_meta( $current_user->id, 'custom_field_'.$value['id'], $upFile); |
| 224 |
$pictureUpload = 'yes'; |
| 225 |
}else{ |
| 226 |
//insert the name of the file in an array so that in case an error comes up, we know which files we just uploaded |
| 227 |
array_push($uploadName, basename( $_FILES[$uploadedfile]['name'])); |
| 228 |
} |
| 229 |
}else{ |
| 230 |
//insert the name of the file in an array so that in case an error comes up, we know which files we just uploaded |
| 231 |
array_push($uploadName, basename( $_FILES[$uploadedfile]['name'])); |
| 232 |
} |
| 233 |
} |
| 234 |
break; |
| 235 |
} |
| 236 |
case "avatar":{ |
| 237 |
$avatarUpload = 'no'; |
| 238 |
$uploadedfile = $value['item_type'].$value['id']; |
| 239 |
$target_path_original = "wp-content/uploads/profile_builder/avatars/"; |
| 240 |
$fileName = $_FILES[$uploadedfile]['name']; |
| 241 |
$finalFileName = ''; |
| 242 |
|
| 243 |
for ($i=0; $i < strlen($fileName); $i++){ |
| 244 |
if ($fileName[$i] == "'") |
| 245 |
$finalFileName .= '`'; |
| 246 |
elseif ($fileName[$i] == ' ') |
| 247 |
$finalFileName .= '_'; |
| 248 |
else $finalFileName .= $fileName[$i]; |
| 249 |
} |
| 250 |
|
| 251 |
$fileName = $finalFileName; |
| 252 |
|
| 253 |
$target_path = $target_path_original . 'userID_'.$current_user->id.'_originalAvatar_'. $fileName; |
| 254 |
$target_path_avatar = $target_path_original . 'userID_'.$current_user->id.'_resziedAvatarSize_'.$value['item_options'].'_orignalName_'.$fileName; |
| 255 |
|
| 256 |
/* when trying to upload file, be sure it's one of the accepted image file-types */ |
| 257 |
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)) ){ |
| 258 |
$avatarUpload = 'yes'; |
| 259 |
$wp_filetype = wp_check_filetype(basename( $_FILES[$uploadedfile]['name']), null ); |
| 260 |
$attachment = array( |
| 261 |
'post_mime_type' => $wp_filetype['type'], |
| 262 |
'post_title' => $fileName, |
| 263 |
'post_content' => '', |
| 264 |
'post_status' => 'inherit' |
| 265 |
); |
| 266 |
|
| 267 |
|
| 268 |
$attach_id = wp_insert_attachment( $attachment, $target_path); |
| 269 |
$attach_id_avatar = wp_insert_attachment( $attachment, $target_path_avatar); |
| 270 |
|
| 271 |
$upFile = image_downsize( $attach_id, 'thumbnail' ); |
| 272 |
$upFile_avatar = image_downsize( $attach_id_avatar, 'thumbnail' ); |
| 273 |
$upFile = $upFile[0]; |
| 274 |
$upFile_avatar = $upFile_avatar[0]; |
| 275 |
|
| 276 |
//calculate memory needed for file creation and allocate dynamically, in case of large files |
| 277 |
$memoryNeeded = round(($upFile[0] * $upFile[1] * $upFile['bits'] * $upFile['channels'] / 8 + Pow(2, 16)) * 1.8); |
| 278 |
$memoryHave = memory_get_usage(); |
| 279 |
$memoryHave = memoryHave * Pow(1024,2); |
| 280 |
$memoryLimitMB = ini_get('memory_limit'); |
| 281 |
$memoryLimit = substr ( $memoryLimitMB, 0, strlen($memoryLimitMB)-1 ); |
| 282 |
$memoryLimit = $memoryLimit * Pow(1024,2); |
| 283 |
|
| 284 |
$newLimit = ceil( (($memoryHave + $memoryNeeded + $memoryLimit) / Pow(1024,2)) * 1.8 ); |
| 285 |
ini_set( 'memory_limit', $newLimit . 'M' ); |
| 286 |
|
| 287 |
//if file upload succeded |
| 288 |
if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)){ |
| 289 |
// update the usermeta field with the original file url |
| 290 |
update_user_meta( $current_user->id, 'custom_field_'.$value['id'], $upFile); |
| 291 |
|
| 292 |
// also upload a resized image of it |
| 293 |
(move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path_avatar)); |
| 294 |
|
| 295 |
|
| 296 |
$extension = str_replace ( 'image/' , '' , $_FILES[$uploadedfile]['type']); |
| 297 |
if($extension=="jpg" || $extension=="jpeg" || $extension=="pjpeg" ) |
| 298 |
$src = imagecreatefromjpeg($upFile); |
| 299 |
elseif($extension=="png" || $extension=="x-png") |
| 300 |
$src = imagecreatefrompng($upFile); |
| 301 |
else |
| 302 |
$src = imagecreatefromgif($upFile); |
| 303 |
|
| 304 |
list($width,$height)=getimagesize($upFile); |
| 305 |
|
| 306 |
$newwidth=$value['item_options']; |
| 307 |
$newheight=$value['item_options']; |
| 308 |
$tmp=imagecreatetruecolor($newwidth,$newheight); |
| 309 |
|
| 310 |
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); |
| 311 |
$filename = $target_path_avatar; |
| 312 |
|
| 313 |
imagejpeg($tmp,$filename,100); |
| 314 |
|
| 315 |
imagedestroy($src); |
| 316 |
imagedestroy($tmp); |
| 317 |
|
| 318 |
//restore the old value of the memory after imageprocessing is done |
| 319 |
ini_restore ( 'memory_limit' ); |
| 320 |
|
| 321 |
// update/add a new usermeta field containing the url to the resized image |
| 322 |
update_user_meta( $current_user->id, 'custom_field_resized'.$value['id'], $upFile_avatar); |
| 323 |
} |
| 324 |
else $avatarUpload = 'no'; |
| 325 |
}elseif ( (($_FILES[$uploadedfile]['size'] > ServerMaxUploadSizeByte) || ($_FILES[$uploadedfile]['size'] == 0)) && ($fileName != '') ) |
| 326 |
$avatarUpload = 'no'; |
| 327 |
elseif ($fileName == '') |
| 328 |
$avatarUpload = 'yes'; |
| 329 |
break; |
| 330 |
} |
| 331 |
} |
| 332 |
} |
| 333 |
} |
| 334 |
|
| 335 |
} |
| 336 |
|
| 337 |
?> |
| 338 |
<div class="wppb_holder" id="wppb_modify"> |
| 339 |
<?php if ( !is_user_logged_in() ) : ?> |
| 340 |
|
| 341 |
<p class="warning"> |
| 342 |
<?php _e('You must be logged in to edit your profile.', 'profilebuilder'); ?> |
| 343 |
</p><!-- .warning --> |
| 344 |
|
| 345 |
<?php else : |
| 346 |
{ |
| 347 |
/* messages for the the delete avatar/attachment */ |
| 348 |
if (isset($_GET['fileType'])){ |
| 349 |
if ($_GET['fileType'] == 'avatar'){ |
| 350 |
echo '<p class="changes-saved">'; |
| 351 |
_e('The avatar was successfully deleted.', 'profilebuilder'); |
| 352 |
echo'</p><!-- .changes-saved -->'; |
| 353 |
unset($_GET['fileType']); |
| 354 |
}elseif ($_GET['fileType'] == 'attachment'){ |
| 355 |
echo '<p class="changes-saved">'; |
| 356 |
_e('The attachment "', 'profilebuilder'); |
| 357 |
echo $_GET['fileName']; |
| 358 |
_e('" was successfully deleted.', 'profilebuilder'); |
| 359 |
echo'</p><!-- .changes-saved -->'; |
| 360 |
unset($_GET['fileType']); |
| 361 |
unset($_GET['fileName']); |
| 362 |
} |
| 363 |
} |
| 364 |
|
| 365 |
/* all the other messages/errors */ |
| 366 |
$nrOfBadUploads = 0; |
| 367 |
$nrOfBadUploads = count($uploadName); |
| 368 |
|
| 369 |
if (($changesSaved == 'yes') && ($changesSavedNoMatchingPass == 'no') && ($changesSavedNoPass == 'no') && ($changesSavedNoEmail == 'no') && ($changesSavedNoEmailExist == 'no') && ($avatarUpload == 'yes') && ($nrOfBadUploads == 0)){ |
| 370 |
echo '<p class="changes-saved">'; |
| 371 |
_e('The changes have been successfully saved.', 'profilebuilder'); |
| 372 |
echo'</p><!-- .changes-saved -->'; |
| 373 |
} |
| 374 |
elseif (($changesSaved == 'yes') && ($changesSavedNoEmailExist == 'yes') && ($previousError == 'no')){ |
| 375 |
echo '<p class="semi-saved">'; |
| 376 |
_e('The email address you entered is already registered to a different user.<br/>The email address was ', 'profilebuilder'); |
| 377 |
echo'<span class="error">'; _e('NOT', 'profilebuilder');echo'</span>'; |
| 378 |
_e(' updated along with the rest of the information.', 'profilebuilder'); |
| 379 |
echo '</p>'; |
| 380 |
$previousError = 'yes'; |
| 381 |
} |
| 382 |
|
| 383 |
if (($changesSaved == 'yes') && ($changesSavedNoEmail == 'yes') && ($previousError == 'no')){ |
| 384 |
echo '<p class="semi-saved">'; |
| 385 |
_e('The email address you entered is invalid. <br/> The email address was ', 'profilebuilder'); |
| 386 |
echo'<span class="error">'; _e('NOT', 'profilebuilder');echo'</span>'; |
| 387 |
_e(' updated along with the rest of the information.', 'profilebuilder'); |
| 388 |
echo '</p>'; |
| 389 |
$previousError = 'yes'; |
| 390 |
} |
| 391 |
|
| 392 |
if (($changesSaved == 'yes') && ($changesSavedNoMatchingPass == 'yes') && ($previousError == 'no')){ |
| 393 |
echo '<p class="semi-saved">'; |
| 394 |
_e('The passwords you entered do not match. <br/> The password was ', 'profilebuilder'); |
| 395 |
echo'<span class="error">'; _e('NOT', 'profilebuilder');echo'</span>'; |
| 396 |
_e(' updated along with the rest of the information.', 'profilebuilder'); |
| 397 |
echo '</p>'; |
| 398 |
$previousError = 'yes'; |
| 399 |
} |
| 400 |
if (($changesSaved == 'yes') && ($changesSavedNoPass == 'yes') && ($previousError == 'no')){ |
| 401 |
echo '<p class="semi-saved">'; |
| 402 |
_e('You didn\'t complete both password fields. <br/> The password was ', 'profilebuilder'); |
| 403 |
echo'<span class="error">'; _e('NOT', 'profilebuilder');echo'</span>'; |
| 404 |
_e(' updated along with the rest of the information.', 'profilebuilder'); |
| 405 |
echo '</p>'; |
| 406 |
$previousError = 'yes'; |
| 407 |
} |
| 408 |
$wppb_premium = wppb_plugin_dir . '/premium/functions/'; |
| 409 |
if (file_exists ( $wppb_premium.'extra.fields.php' )){ |
| 410 |
if (($changesSaved == 'yes') && ($nrOfBadUploads > 0) && ($previousError == 'no')){ |
| 411 |
$lastOne = 0; |
| 412 |
echo '<p class="semi-saved">'; |
| 413 |
_e('There was an error while trying to upload the following attachments:<br/>', 'profilebuilder'); |
| 414 |
echo '<span class="error">'; |
| 415 |
foreach ($uploadName as $key => $name){ |
| 416 |
$lastOne++; |
| 417 |
echo $name; |
| 418 |
if ($nrOfBadUploads-$lastOne > 0) echo ';<span style="padding-left:10px"></span>'; |
| 419 |
} |
| 420 |
echo '</span>'; |
| 421 |
_e('<br/>Possible cause: the size was bigger than ', 'profilebuilder'); |
| 422 |
echo ServerMaxUploadSizeMega; |
| 423 |
_e('b.<br/>The listed attachements were ', 'profilebuilder'); |
| 424 |
echo'<span class="error">'; _e('NOT', 'profilebuilder');echo'</span>'; |
| 425 |
_e(' updated along with the rest of the information.', 'profilebuilder'); |
| 426 |
echo '</p>'; |
| 427 |
$previousError = 'yes'; |
| 428 |
} if (($changesSaved == 'yes') && ($avatarUpload == 'no') && ($previousError == 'no')){ |
| 429 |
echo '<p class="semi-saved">'; |
| 430 |
_e('There was an error while trying to upload your avatar picture.<br/>Possible cause: size/incorrect file-type.<br/>The avatar was ', 'profilebuilder'); |
| 431 |
echo'<span class="error">'; _e('NOT', 'profilebuilder');echo'</span>'; |
| 432 |
_e(' updated along with the rest of the information.', 'profilebuilder'); |
| 433 |
echo '</p>'; |
| 434 |
$previousError = 'yes'; |
| 435 |
} |
| 436 |
} |
| 437 |
} |
| 438 |
|
| 439 |
?> |
| 440 |
|
| 441 |
<?php /* use this action hook to add extra content before the edit profile form. */ ?> |
| 442 |
<?php do_action( 'wppb_before_edit_profile_fields' ); ?> |
| 443 |
|
| 444 |
<form enctype="multipart/form-data" method="post" id="edituser" class="user-forms" action="<?php the_permalink(); ?>"> |
| 445 |
<?php 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 --> |
| 446 |
|
| 447 |
<p> |
| 448 |
<strong><?php _e('Name', 'profilebuilder');?></strong> |
| 449 |
</p> |
| 450 |
<?php |
| 451 |
if ($wppb_defaultOptions['username'] == 'show'){ echo' |
| 452 |
<p class="username"> |
| 453 |
<label for="user_login">'; _e('Username', 'profilebuilder'); echo'</label> |
| 454 |
<input class="text-input" name="user_login" type="text" id="user_login" value="'; the_author_meta( 'user_login', $current_user->id ); echo'" disabled="disabled"/> <span class="wppb-description-delimiter">'; _e(' Usernames cannot be changed.'); echo'</span> |
| 455 |
</p><!-- .first_name -->'; |
| 456 |
} |
| 457 |
?> |
| 458 |
|
| 459 |
<?php |
| 460 |
if ($wppb_defaultOptions['firstname'] == 'show'){ echo' |
| 461 |
<p class="first_name"> |
| 462 |
<label for="first_name">'; _e('First Name', 'profilebuilder'); echo'</label> |
| 463 |
<input class="text-input" name="first_name" type="text" id="first_name" value="'; the_author_meta( 'first_name', $current_user->id ); echo '" /> |
| 464 |
</p><!-- .first_name -->'; |
| 465 |
} |
| 466 |
?> |
| 467 |
|
| 468 |
<?php |
| 469 |
if ($wppb_defaultOptions['lastname'] == 'show'){ echo' |
| 470 |
<p class="last_name"> |
| 471 |
<label for="last_name">'; _e('Last Name', 'profilebuilder'); echo'</label> |
| 472 |
<input class="text-input" name="last_name" type="text" id="last_name" value="'; the_author_meta( 'last_name', $current_user->id ); echo '" /> |
| 473 |
</p><!-- .last_name -->'; |
| 474 |
} |
| 475 |
?> |
| 476 |
|
| 477 |
<?php |
| 478 |
if ($wppb_defaultOptions['nickname'] == 'show'){ echo' |
| 479 |
<p class="nickname"> |
| 480 |
<label for="nickname">'; _e('Nickname', 'profilebuilder'); echo '</label> |
| 481 |
<input class="text-input" name="nickname" type="text" id="nickname" value="'; the_author_meta( 'nickname', $current_user->id ); echo'" /> |
| 482 |
<span class="wppb-description-delimiter">'; _e('(required)', 'profilebuilder');echo'</span> |
| 483 |
</p><!-- .nickname -->'; |
| 484 |
} |
| 485 |
?> |
| 486 |
|
| 487 |
<?php |
| 488 |
if ($wppb_defaultOptions['dispname'] == 'show'){ echo' |
| 489 |
<p class="display_name"> |
| 490 |
<label for="display_name">'; _e('Display name publicly as', 'profilebuilder'); echo'</label> |
| 491 |
<select name="display_name" id="display_name">'; |
| 492 |
$public_display = array(); |
| 493 |
$public_display['display_username'] = get_the_author_meta('user_login', $current_user->id); |
| 494 |
$thisFirstName = get_the_author_meta('first_name', $current_user->id); |
| 495 |
if ( !empty($thisFirstName)) |
| 496 |
$public_display['display_firstname'] = get_the_author_meta('first_name', $current_user->id); |
| 497 |
$thisLastName = get_the_author_meta('last_name', $current_user->id); |
| 498 |
if ( !empty($thisLastName)) |
| 499 |
$public_display['display_lastname'] = get_the_author_meta('last_name', $current_user->id); |
| 500 |
$public_display['display_nickname'] = get_the_author_meta('nickname', $current_user->id); |
| 501 |
if ( !empty($thisFirstName) && !empty($thisLastName) ) { |
| 502 |
$public_display['display_firstlast'] = $thisFirstName . ' ' . $thisLastName; |
| 503 |
$public_display['display_lastfirst'] = $thisLastName . ' ' . $thisFirstName; |
| 504 |
} |
| 505 |
$thisDisplayName = get_the_author_meta('display_name', $current_user->id); |
| 506 |
if ( !in_array( $thisDisplayName, $public_display ) ) // Only add this if it isn't duplicated elsewhere |
| 507 |
$public_display = array( 'display_displayname' => $thisDisplayName ) + $public_display; |
| 508 |
$public_display = array_map( 'trim', $public_display ); |
| 509 |
foreach ( $public_display as $id => $item ) { |
| 510 |
echo '<option id="'.$id.'" value="'.$item.'"'; selected( $thisDisplayName, $item ); echo'>'.$item.'</option>'; |
| 511 |
} |
| 512 |
echo'</select> |
| 513 |
</p><!-- .display_name -->'; |
| 514 |
} |
| 515 |
?> |
| 516 |
|
| 517 |
|
| 518 |
<p> |
| 519 |
<strong><?php _e('Contact Info', 'profilebuilder');?></strong> |
| 520 |
</p> |
| 521 |
|
| 522 |
<?php |
| 523 |
if ($wppb_defaultOptions['email'] == 'show'){ echo' |
| 524 |
<p class="form-email"> |
| 525 |
<label for="email">'; _e('E-mail', 'profilebuilder');echo '</label> |
| 526 |
<input class="text-input" name="email" type="text" id="email" value="'; the_author_meta( 'user_email', $current_user->id ); echo'" /> |
| 527 |
<span class="wppb-description-delimiter">'; _e('(required)', 'profilebuilder');echo'</span> |
| 528 |
</p><!-- .form-email -->'; |
| 529 |
} |
| 530 |
?> |
| 531 |
|
| 532 |
<?php |
| 533 |
if ($wppb_defaultOptions['website'] == 'show'){ echo' |
| 534 |
<p class="form-website"> |
| 535 |
<label for="website">'; _e('Website', 'profilebuilder'); echo'</label> |
| 536 |
<input class="text-input" name="website" type="text" id="website" value="'; the_author_meta( 'user_url', $current_user->id ); echo'" /> |
| 537 |
</p><!-- .form-website -->'; |
| 538 |
} |
| 539 |
?> |
| 540 |
|
| 541 |
<?php |
| 542 |
if ($wppb_defaultOptions['aim'] == 'show'){ echo' |
| 543 |
<p class="form-aim"> |
| 544 |
<label for="aim">'; _e('AIM', 'profilebuilder'); echo'</label> |
| 545 |
<input class="text-input" name="aim" type="text" id="aim" value="'; the_author_meta( 'aim', $current_user->id ); echo'" /> |
| 546 |
</p><!-- .form-aim -->'; |
| 547 |
} |
| 548 |
?> |
| 549 |
|
| 550 |
<?php |
| 551 |
if ($wppb_defaultOptions['yahoo'] == 'show'){ echo' |
| 552 |
<p class="form-yim"> |
| 553 |
<label for="yim">'; _e('Yahoo IM', 'profilebuilder'); echo'</label> |
| 554 |
<input class="text-input" name="yim" type="text" id="yim" value="'; the_author_meta( 'yim', $current_user->id ); echo'" /> |
| 555 |
</p><!-- .form-yim -->'; |
| 556 |
} |
| 557 |
?> |
| 558 |
|
| 559 |
<?php |
| 560 |
if ($wppb_defaultOptions['jabber'] == 'show'){ echo' |
| 561 |
<p class="form-jabber"> |
| 562 |
<label for="jabber">'; _e('Jabber / Google Talk', 'profilebuilder'); echo'</label> |
| 563 |
<input class="text-input" name="jabber" type="text" id="jabber" value="'; the_author_meta( 'jabber', $current_user->id ); echo'" /> |
| 564 |
</p><!-- .form-jabber -->'; |
| 565 |
} |
| 566 |
?> |
| 567 |
|
| 568 |
<p> |
| 569 |
<strong><?php _e('About Yourself', 'profilebuilder');?></strong> |
| 570 |
</p> |
| 571 |
|
| 572 |
<?php |
| 573 |
if ($wppb_defaultOptions['bio'] == 'show'){ echo' |
| 574 |
<p class="form-description"> |
| 575 |
<label for="description">'; _e('Biographical Info', 'profilebuilder'); echo'</label> |
| 576 |
<textarea class="text-input" name="description" id="description" rows="5" cols="30">'; the_author_meta( 'description', $current_user->id ); echo'</textarea> |
| 577 |
</p><!-- .form-description -->'; |
| 578 |
} |
| 579 |
?> |
| 580 |
|
| 581 |
<?php |
| 582 |
if ($wppb_defaultOptions['password'] == 'show'){ echo' |
| 583 |
<p class="form-password"> |
| 584 |
<label for="pass1">'; _e('New Password', 'profilebuilder'); echo'</label> |
| 585 |
<input class="text-input" name="pass1" type="password" id="pass1" /> |
| 586 |
</p><!-- .form-password --> |
| 587 |
|
| 588 |
<p class="form-password"> |
| 589 |
<label for="pass2">'; _e('Repeat Password', 'profilebuilder'); echo'</label> |
| 590 |
<input class="text-input" name="pass2" type="password" id="pass2" /> |
| 591 |
</p><!-- .form-password -->'; |
| 592 |
} |
| 593 |
?> |
| 594 |
|
| 595 |
<?php |
| 596 |
$wppb_premium = wppb_plugin_dir . '/premium/functions/'; |
| 597 |
if (file_exists ( $wppb_premium.'extra.fields.php' )){ |
| 598 |
require_once($wppb_premium.'extra.fields.php'); |
| 599 |
edit_profile_extra_fields($current_user->id); |
| 600 |
} |
| 601 |
?> |
| 602 |
|
| 603 |
|
| 604 |
<p class="form-submit"> |
| 605 |
<input name="updateuser" type="submit" id="updateuser" class="submit button" value="<?php _e('Update', 'profilebuilder'); ?>" /> |
| 606 |
<?php// wp_nonce_field( 'update-user' ) ?> |
| 607 |
<input name="action" type="hidden" id="action" value="update-user" /> |
| 608 |
</p><!-- .form-submit --> |
| 609 |
<?php wp_nonce_field('verify_edit_user','edit_nonce_field'); ?> |
| 610 |
</form><!-- #edituser --> |
| 611 |
|
| 612 |
<?php endif; ?> |
| 613 |
|
| 614 |
<?php /* use this action hook to add extra content after the edit profile form. */ ?> |
| 615 |
<?php do_action( 'wppb_after_edit_profile_fields' ); ?> |
| 616 |
|
| 617 |
</div> |
| 618 |
|
| 619 |
<?php |
| 620 |
$output = ob_get_contents(); |
| 621 |
ob_end_clean(); |
| 622 |
|
| 623 |
$output = apply_filters ('wppb_edit_profile', $output); |
| 624 |
|
| 625 |
return $output; |
| 626 |
} |
| 627 |
?> |