function wppb_front_end_register($atts) { ob_start(); global $current_user; global $wp_roles; global $wpdb; global $error; global $wppb_shortcode_on_front; //get required and shown fields $wppb_defaultOptions = get_option('wppb_default_settings'); //get "login with" setting $wppb_generalSettings = get_option('wppb_general_settings'); $wppb_shortcode_on_front = true; $agreed = true; $new_user = '******'; $multisite_message = false; $registerFilterArray = array(); $registerFilterArray2 = array(); $uploadExt = array(); $extraFieldsErrorHolder = array(); //we will use this array to store the ID's of the extra-fields left uncompleted get_currentuserinfo(); /* variables used to verify if all required fields were submitted*/ $firstnameComplete = 'yes'; $lastnameComplete = 'yes'; $nicknameComplete = 'yes'; $websiteComplete = 'yes'; $aimComplete = 'yes'; $yahooComplete = 'yes'; $jabberComplete = 'yes'; $bioComplete = 'yes'; /* END variables used to verify if all required fields were submitted*/ /* Check if users can register. */ $registration = get_option('users_can_register'); $registration = apply_filters('wppb_register_setting_override', $registration); //fallback if the file was largen then post_max_size, case in which no errors can be saved in $_FILES[fileName]['error'] if (empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post') { $registerFilterArray['noPostError'] = '<p class="error">' . sprintf(__('The information size you were trying to submit was larger than %1$sb!<br/>This is usually caused by a large file(s) trying to be uploaded.<br/>Since it was also larger than %2$sb no additional information is available.<br/>The user was NOT created!', 'profilebuilder'), WPPB_SERVER_MAX_UPLOAD_SIZE_MEGA, WPPB_SERVER_MAX_POST_SIZE_MEGA) . '</p>'; echo $registerFilterArray['noPostError'] = apply_filters('wppb_register_no_post_error_message', $registerFilterArray['noPostError'], WPPB_SERVER_MAX_UPLOAD_SIZE_MEGA, WPPB_SERVER_MAX_POST_SIZE_MEGA); } /* If user registered, input info. */ if ('POST' == $_SERVER['REQUEST_METHOD'] && !empty($_POST['action']) && $_POST['action'] == 'adduser' && wp_verify_nonce($_POST['register_nonce_field'], 'verify_true_registration') && $_POST['formName'] == 'register') { //global $wp_roles; //get value sent in the shortcode as parameter, use default if not set $default_role = get_option('default_role'); extract(shortcode_atts(array('role' => $default_role), $atts)); //check if the specified role exists in the database, else fall back to the "safe-zone" $aprovedRole = $role == $default_role || get_role($role) ? $role : $default_role; /* preset the values in case some are not submitted */ $user_pass = ''; if (isset($_POST['passw1'])) { $user_pass = esc_attr($_POST['passw1']); } $email = ''; if (isset($_POST['email'])) { $email = trim($_POST['email']); } if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') { $user_name = wppb_generate_random_username($email); } else { $user_name = ''; if (isset($_POST['user_name'])) { $user_name = trim($_POST['user_name']); } } $first_name = ''; if (isset($_POST['first_name'])) { $first_name = trim($_POST['first_name']); } $last_name = ''; if (isset($_POST['last_name'])) { $last_name = trim($_POST['last_name']); } $nickname = ''; if (isset($_POST['nickname'])) { //the field is filled by the user upon registration $nickname = trim($_POST['nickname']); } elseif (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') { //in case the nickname field is hidden, and the login with email is active $nickname = $email; } else { //in case the nickname field is hidden, but login is done with username $nickname = $user_name; } $website = ''; if (isset($_POST['website'])) { $website = trim($_POST['website']); } $aim = ''; if (isset($_POST['aim'])) { $aim = trim($_POST['aim']); } $yim = ''; if (isset($_POST['yim'])) { $yim = trim($_POST['yim']); } $jabber = ''; if (isset($_POST['jabber'])) { $jabber = trim($_POST['jabber']); } $description = ''; if (isset($_POST['description'])) { $description = trim($_POST['description']); } /* use filters to modify (if needed) the posted data before creating the user-data */ $user_pass = apply_filters('wppb_register_posted_password', $user_pass); $user_name = apply_filters('wppb_register_posted_username', $user_name); $first_name = apply_filters('wppb_register_posted_first_name', $first_name); $last_name = apply_filters('wppb_register_posted_last_name', $last_name); $nickname = apply_filters('wppb_register_posted_nickname', $nickname); $email = apply_filters('wppb_register_posted_email', $email); $website = apply_filters('wppb_register_posted_website', $website); $aim = apply_filters('wppb_register_posted_aim', $aim); $yim = apply_filters('wppb_register_posted_yahoo', $yim); $jabber = apply_filters('wppb_register_posted_jabber', $jabber); $description = apply_filters('wppb_register_posted_bio', $description); /* END use filters to modify (if needed) the posted data before creating the user-data */ $userdata = array('user_pass' => $user_pass, 'user_login' => esc_attr($user_name), 'first_name' => esc_attr($first_name), 'last_name' => esc_attr($last_name), 'nickname' => esc_attr($nickname), 'user_email' => esc_attr($email), 'user_url' => esc_attr($website), 'aim' => esc_attr($aim), 'yim' => esc_attr($yim), 'jabber' => esc_attr($jabber), 'description' => esc_attr($description), 'role' => $aprovedRole); $userdata = apply_filters('wppb_register_userdata', $userdata); //check if the user agreed to the terms and conditions (if it was set) $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/'; if (file_exists($wppb_premium . 'extra.fields.php')) { $wppbFetchArray = get_option('wppb_custom_fields'); foreach ($wppbFetchArray as $key => $value) { switch ($value['item_type']) { case "agreeToTerms": $agreed = false; if (isset($_POST[$value['item_type'] . $value['id']]) && $_POST[$value['item_type'] . $value['id']] == 'agree') { $agreed = true; } break; } // add filters for all the custom fields $_POST[$value['item_type'] . $value['id']] = apply_filters('wppb_register_' . $value['item_type'] . $value['id'] . '_general_filter', $_POST[$value['item_type'] . $value['id']]); } } $registerFilterArray['extraError'] = ''; //this is for creating extra error message and bypassing registration $registerFilterArray['extraError'] = apply_filters('wppb_register_extra_error', $registerFilterArray['extraError']); /* check if all the required fields were completed */ if ($wppb_defaultOptions['firstname'] == 'show') { if ($wppb_defaultOptions['firstnameRequired'] == 'yes' && trim($_POST['first_name']) == '') { $firstnameComplete = 'no'; } } if ($wppb_defaultOptions['lastname'] == 'show') { if ($wppb_defaultOptions['lastnameRequired'] == 'yes' && trim($_POST['last_name']) == '') { $lastnameComplete = 'no'; } } if ($wppb_defaultOptions['nickname'] == 'show') { if ($wppb_defaultOptions['nicknameRequired'] == 'yes' && trim($_POST['nickname']) == '') { $nicknameComplete = 'no'; } } if ($wppb_defaultOptions['website'] == 'show') { if ($wppb_defaultOptions['websiteRequired'] == 'yes' && trim($_POST['website']) == '') { $websiteComplete = 'no'; } } if ($wppb_defaultOptions['aim'] == 'show') { if ($wppb_defaultOptions['aimRequired'] == 'yes' && trim($_POST['aim']) == '') { $aimComplete = 'no'; } } if ($wppb_defaultOptions['yahoo'] == 'show') { if ($wppb_defaultOptions['yahooRequired'] == 'yes' && trim($_POST['yahoo']) == '') { $yahooComplete = 'no'; } } if ($wppb_defaultOptions['jabber'] == 'show') { if ($wppb_defaultOptions['jabberRequired'] == 'yes' && trim($_POST['jabber']) == '') { $jabberComplete = 'no'; } } if ($wppb_defaultOptions['bio'] == 'show') { if ($wppb_defaultOptions['bioRequired'] == 'yes' && trim($_POST['description']) == '') { $bioComplete = 'no'; } } // check the extra fields also $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/'; if (file_exists($wppb_premium . 'extra.fields.php')) { $wppbFetchArray = get_option('wppb_custom_fields'); foreach ($wppbFetchArray as $key => $value) { switch ($value['item_type']) { case "input": $_POST[$value['item_type'] . $value['id']] = apply_filters('wppb_register_input_custom_field_' . $value['id'], $_POST[$value['item_type'] . $value['id']]); if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); } } } break; case "checkbox": $checkboxOption = ''; $value['item_options'] = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $id . '_options_translation', $value['item_options']); $checkboxValue = explode(',', $value['item_options']); foreach ($checkboxValue as $thisValue) { $thisValue = str_replace(' ', '#@space@#', $thisValue); //we need to escape the space-codification we sent earlier in the post if (isset($_POST[$thisValue . $value['id']])) { $localValue = str_replace('#@space@#', ' ', $_POST[$thisValue . $value['id']]); $checkboxOption = $checkboxOption . $localValue . ','; } } if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($checkboxOption) == '') { array_push($extraFieldsErrorHolder, $value['id']); } } } break; case "radio": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); } } } break; case "select": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); } } } break; case "countrySelect": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); } } } break; case "timeZone": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); } } } break; case "datepicker": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); } } } break; case "textarea": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if (trim($_POST[$value['item_type'] . $value['id']]) == '') { array_push($extraFieldsErrorHolder, $value['id']); } } } break; case "upload": $uploadedfile = $value['item_type'] . $value['id']; if (basename($_FILES[$uploadedfile]['name']) == '') { if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { array_push($extraFieldsErrorHolder, $value['id']); } } } elseif (basename($_FILES[$uploadedfile]['name']) != '') { //get allowed file types if ($value['item_options'] != NULL || $value['item_options'] != '') { $allFiles = false; $extensions = explode(',', $value['item_options']); foreach ($extensions as $key2 => $value2) { $extensions[$key2] = trim($value2); } } else { $allFiles = true; } $thisFileExtStart = strrpos($_FILES[$uploadedfile]['name'], '.'); $thisFileExt = substr($_FILES[$uploadedfile]['name'], $thisFileExtStart); if ($allFiles == false && !in_array($thisFileExt, $extensions)) { array_push($uploadExt, basename($_FILES[$uploadedfile]['name'])); $allowedExtensions = ''; (int) ($nrOfExt = count($extensions) - 2); foreach ($extensions as $key2 => $value2) { $allowedExtensions .= $value2; if ($key2 <= $nrOfExt) { $allowedExtensions .= ', '; } } } } break; case "avatar": $uploadedfile = $value['item_type'] . $value['id']; if (basename($_FILES[$uploadedfile]['name']) == '') { 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') { if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { array_push($extraFieldsErrorHolder, $value['id']); } } } } break; case "agreeToTerms": if (isset($value['item_required'])) { if ($value['item_required'] == 'yes') { if ($_POST[$value['item_type'] . $value['id']] == NULL) { array_push($extraFieldsErrorHolder, $value['id']); } } } break; } } } /* END check if all the required fields were completed */ if ($registerFilterArray['extraError'] != '') { $error = $registerFilterArray['extraError']; } elseif (!$userdata['user_login']) { if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') { } else { $error = apply_filters('wppb_register_userlogin_error1', __('A username is required for registration.', 'profilebuilder')); } } elseif (username_exists($userdata['user_login'])) { if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') { } else { $error = apply_filters('wppb_register_userlogin_error2', __('Sorry, that username already exists!', 'profilebuilder')); } } elseif (!is_email($userdata['user_email'], true)) { $error = apply_filters('wppb_register_useremail_error1', __('You must enter a valid email address.', 'profilebuilder')); } elseif (email_exists($userdata['user_email'])) { $error = apply_filters('wppb_register_useremail_error2', __('Sorry, that email address is already used!', 'profilebuilder')); } elseif (empty($_POST['passw1']) || empty($_POST['passw2']) || $_POST['passw1'] != $_POST['passw2']) { if (empty($_POST['passw1']) || empty($_POST['passw2'])) { //verify if the user has completed both password fields $error = apply_filters('wppb_register_userpass_error1', __('You didn\'t complete one of the password-fields!', 'profilebuilder')); } elseif ($_POST['passw1'] != $_POST['passw2']) { //verify if the the password and the retyped password are a match $error = apply_filters('wppb_register_userpass_error2', __('The entered passwords don\'t match!', 'profilebuilder')); } } elseif (count($uploadExt) > 0) { $error = '<p class="semi-saved">' . __('There was an error while trying to upload the following attachment(s)', 'profilebuilder') . ': <span class="error">'; foreach ($uploadExt as $key5 => $name5) { $lastOne++; $error .= $name5; if (count($uploadExt) - $lastOne > 0) { $error .= ';<span style="padding-left:10px"></span>'; } } $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> </p>'; } elseif ($agreed == false) { $error = __('You must agree to the terms and conditions before registering!', 'profilebuilder'); } elseif ($firstnameComplete == 'no' || $lastnameComplete == 'no' || $nicknameComplete == 'no' || $websiteComplete == 'no' || $aimComplete == 'no' || $yahooComplete == 'no' || $jabberComplete == 'no' || $bioComplete == 'no' || !empty($extraFieldsErrorHolder)) { $error = __('The account was NOT created!', 'profilebuilder') . '<br/>' . __('(Several required fields were left uncompleted)', 'profilebuilder'); } else { $registered_name = $_POST['user_name']; //register the user normally if it is not a multi-site installation if (!is_multisite()) { $wppb_generalSettings = get_option('wppb_general_settings'); if ($wppb_generalSettings['emailConfirmation'] == 'yes') { $foundError = false; if (is_multisite()) { $userSignup = $wpdb->get_results("SELECT * FROM {$wpdb->signups} WHERE user_login='******'user_login'] . "' OR user_email='" . $userdata['user_email'] . "'"); } else { $userSignup = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "signups WHERE user_login='******'user_login'] . "' OR user_email='" . $userdata['user_email'] . "'"); } if (trim($userSignup[0]->user_login) == $userdata['user_login']) { $foundError = true; $error = __('This username is already reserved to be used soon.', 'profilebuilder') . '<br/>' . __('Please try a different one!', 'profilebuilder'); } elseif (trim($userSignup[0]->user_email) == $userdata['user_email']) { $foundError = true; $error = __('This email address is already reserved to be used soon.', 'profilebuilder') . '<br/>' . __('Please try a different one!', 'profilebuilder'); } if ($foundError) { } else { $new_user = '******'; $multisite_message = true; $meta = array('user_pass' => base64_encode($userdata['user_pass']), 'first_name' => $userdata['first_name'], 'last_name' => $userdata['last_name'], 'nickname' => $userdata['nickname'], 'user_url' => $userdata['user_url'], 'aim' => $userdata['aim'], 'yim' => $userdata['yim'], 'jabber' => $userdata['jabber'], 'description' => $userdata['description'], 'role' => $userdata['role']); $meta = wppb_add_custom_field_values($_POST, $meta); wppb_signup_user($userdata['user_login'], $userdata['user_email'], $meta); } } else { $new_user = wp_insert_user($userdata); /* add the extra profile information */ $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/'; if (file_exists($wppb_premium . 'extra.fields.php')) { $wppbFetchArray = get_option('wppb_custom_fields'); foreach ($wppbFetchArray as $key => $value) { switch ($value['item_type']) { case "input": add_user_meta($new_user, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); break; case "hiddenInput": add_user_meta($new_user, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); break; case "checkbox": $checkboxOption = ''; $value['item_options'] = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $id . '_options_translation', $value['item_options']); $checkboxValue = explode(',', $value['item_options']); foreach ($checkboxValue as $thisValue) { $thisValue = str_replace(' ', '#@space@#', $thisValue); //we need to escape the space-codification we sent earlier in the post if (isset($_POST[$thisValue . $value['id']])) { $localValue = str_replace('#@space@#', ' ', $_POST[$thisValue . $value['id']]); $checkboxOption = $checkboxOption . $localValue . ','; } } add_user_meta($new_user, $value['item_metaName'], $checkboxOption); break; case "radio": add_user_meta($new_user, $value['item_metaName'], $_POST[$value['item_type'] . $value['id']]); break; case "select": add_user_meta($new_user, $value['item_metaName'], $_POST[$value['item_type'] . $value['id']]); break; case "countrySelect": update_user_meta($new_user, $value['item_metaName'], $_POST[$value['item_type'] . $value['id']]); break; case "timeZone": update_user_meta($new_user, $value['item_metaName'], $_POST[$value['item_type'] . $value['id']]); break; case "datepicker": update_user_meta($new_user, $value['item_metaName'], $_POST[$value['item_type'] . $value['id']]); break; case "textarea": add_user_meta($new_user, $value['item_metaName'], esc_attr($_POST[$value['item_type'] . $value['id']])); break; case "upload": $uploadedfile = $value['item_type'] . $value['id']; //first we need to verify if we don't try to upload a 0b or 0 length file if (basename($_FILES[$uploadedfile]['name']) != '') { //second we need to verify if the uploaded file size is less then the set file size in php.ini if ($_FILES[$uploadedfile]['size'] < WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE && $_FILES[$uploadedfile]['size'] != 0) { //we need to prepare the basename of the file, so that ' becomes ` as ' gives an error $fileName = basename($_FILES[$uploadedfile]['name']); $finalFileName = ''; for ($i = 0; $i < strlen($fileName); $i++) { if ($fileName[$i] == "'") { $finalFileName .= '`'; } else { $finalFileName .= $fileName[$i]; } } //create the target path for uploading $wpUploadPath = wp_upload_dir(); // Array of key => value pairs $target_path = $wpUploadPath['basedir'] . "/profile_builder/attachments/"; $target_path = $target_path . 'userID_' . $new_user . '_attachment_' . $finalFileName; if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)) { //$upFile = get_bloginfo('home').'/'.$target_path; $upFile = $wpUploadPath['baseurl'] . '/profile_builder/attachments/userID_' . $new_user . '_attachment_' . $finalFileName; add_user_meta($new_user, $value['item_metaName'], $upFile); $pictureUpload = 'yes'; } } } break; case "avatar": $uploadedfile = $value['item_type'] . $value['id']; $wpUploadPath = wp_upload_dir(); // Array of key => value pairs $target_path_original = $wpUploadPath['basedir'] . "/profile_builder/avatars/"; $fileName = $_FILES[$uploadedfile]['name']; $finalFileName = ''; for ($i = 0; $i < strlen($fileName); $i++) { if ($fileName[$i] == "'") { $finalFileName .= '`'; } elseif ($fileName[$i] == ' ') { $finalFileName .= '_'; } else { $finalFileName .= $fileName[$i]; } } $fileName = $finalFileName; $target_path = $target_path_original . 'userID_' . $new_user . '_originalAvatar_' . $fileName; /* when trying to upload file, be sure it's one of the accepted image file-types */ 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)) { $wp_filetype = wp_check_filetype(basename($_FILES[$uploadedfile]['name']), null); $attachment = array('post_mime_type' => $wp_filetype['type'], 'post_title' => $fileName, 'post_content' => '', 'post_status' => 'inherit'); $attach_id = wp_insert_attachment($attachment, $target_path); $upFile = image_downsize($attach_id, 'thumbnail'); $upFile = $upFile[0]; //if file upload succeded if (move_uploaded_file($_FILES[$uploadedfile]['tmp_name'], $target_path)) { add_user_meta($new_user, $value['item_metaName'], $upFile); wppb_resize_avatar($new_user); $avatarUpload = 'yes'; } else { $avatarUpload = 'no'; } } if ($_FILES[$uploadedfile]['type'] == '') { $avatarUpload = 'yes'; } break; } } } // if admin approval is activated, then block the user untill he gets approved $wppb_generalSettings = get_option('wppb_general_settings', 'not_found'); if ($wppb_generalSettings != 'not_found') { if ($wppb_generalSettings['adminApproval'] == 'yes') { wp_set_object_terms($new_user, array('unapproved'), 'user_status', false); clean_object_term_cache($new_user, 'user_status'); } } // send an email to the admin, and - if selected - to the user also. $bloginfo = get_bloginfo('name'); $sentEmailStatus = wppb_notify_user_registration_email($bloginfo, esc_attr($_POST['user_name']), esc_attr($_POST['email']), $_POST['send_credentials_via_email'], $_POST['passw1'], $wppb_generalSettings['adminApproval']); } } elseif (is_multisite()) { //validate username and email $validationRes = wpmu_validate_user_signup($userdata['user_login'], $userdata['user_email']); $error = apply_filters('wppb_register_wpmu_registration_error', $validationRes['errors']->get_error_message()); if (trim($error) != '') { } else { $new_user = '******'; $multisite_message = true; $meta = array('user_pass' => base64_encode($userdata['user_pass']), 'first_name' => $userdata['first_name'], 'last_name' => $userdata['last_name'], 'nickname' => $userdata['nickname'], 'user_url' => $userdata['user_url'], 'aim' => $userdata['aim'], 'yim' => $userdata['yim'], 'jabber' => $userdata['jabber'], 'description' => $userdata['description'], 'role' => $userdata['role']); $meta = wppb_add_custom_field_values($_POST, $meta); wppb_signup_user($userdata['user_login'], $userdata['user_email'], $meta); } } } } ?> <div class="wppb_holder" id="wppb_register"> <?php if (is_user_logged_in() && !current_user_can('create_users')) { global $user_ID; $login = get_userdata($user_ID); if ($login->display_name == '') { $login->display_name = $login->user_login; } $registerFilterArray['loginLogoutError'] = ' <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') . ' »</a></p><!-- .log-in-out .alert -->'; $registerFilterArray['loginLogoutError'] = apply_filters('wppb_register_have_account_alert', $registerFilterArray['loginLogoutError'], $login->ID); echo $registerFilterArray['loginLogoutError']; } elseif ($new_user != 'no') { if (current_user_can('create_users')) { if ($multisite_message) { $registerFilterArray['wpmuRegistrationMessage1'] = '<p class="success">' . sprintf(__('An email has been sent to %1$s with information on how to activate his/her account.', 'profilebuilder'), $userdata['user_email']) . '</p><!-- .success -->'; echo $registerFilterArray['registrationMessage1'] = apply_filters('wppb_wpmu_register_account_created1', $registerFilterArray['wpmuRegistrationMessage1'], $registered_name, $userdata['user_email']); } else { $registerFilterArray['registrationMessage1'] = '<p class="success">' . sprintf(__('A user account has been created for %1$s.', 'profilebuilder'), $registered_name) . '</p><!-- .success -->'; echo $registerFilterArray['registrationMessage1'] = apply_filters('wppb_register_account_created1', $registerFilterArray['registrationMessage1'], $registered_name); } $redirectLink = wppb_curpageurl(); if (file_exists(WPPB_PLUGIN_DIR . '/premium/addons/addon.php')) { //check to see if the redirecting addon is present and activated $wppb_addon_settings = get_option('wppb_addon_settings'); if ($wppb_addon_settings['wppb_customRedirect'] == 'show') { //check to see if the redirect location is not an empty string and is activated $customRedirectSettings = get_option('customRedirectSettings'); if (trim($customRedirectSettings['afterRegisterTarget']) != '' && $customRedirectSettings['afterRegister'] == 'yes') { $redirectLink = trim($customRedirectSettings['afterRegisterTarget']); if (wppb_check_missing_http($redirectLink)) { $redirectLink = 'http://' . $redirectLink; } } } } $registerFilterArray['redirectMessage1'] = '<font id="messageTextColor">' . sprintf(__('You will soon be redirected automatically. If you see this page for more than 3 seconds, please click %1$s.%2$s', 'profilebuilder'), '<a href="' . $redirectLink . '">' . __('here', 'profilebuilder') . '</a>', '<meta http-equiv="Refresh" content="3;url=' . $redirectLink . '" />') . '</font><br/><br/>'; echo $registerFilterArray['redirectMessage1'] = apply_filters('wppb_register_redirect_after_creation1', $registerFilterArray['redirectMessage1'], $redirectLink); } else { if ($multisite_message) { $registerFilterArray['wpmuRegistrationMessage2'] = '<p class="success">' . __('An email has been sent to you with information on how to activate your account.', 'profilebuilder') . '</p><!-- .success -->'; echo $registerFilterArray['wpmuRegistrationMessage2'] = apply_filters('wppb_register_account_created2', $registerFilterArray['wpmuRegistrationMessage2'], $registered_name); } else { $registerFilterArray['registrationMessage2'] = '<p class="success">' . sprintf(__('Thank you for registering %1$s.', 'profilebuilder'), $registered_name) . '</p><!-- .success -->'; echo $registerFilterArray['registrationMessage2'] = apply_filters('wppb_register_account_created2', $registerFilterArray['registrationMessage2'], $registered_name); } $redirectLink = wppb_curpageurl(); if (file_exists(WPPB_PLUGIN_DIR . '/premium/addons/addon.php')) { //check to see if the redirecting addon is present and activated $wppb_addon_settings = get_option('wppb_addon_settings'); if ($wppb_addon_settings['wppb_customRedirect'] == 'show') { //check to see if the redirect location is not an empty string and is activated $customRedirectSettings = get_option('customRedirectSettings'); if (trim($customRedirectSettings['afterRegisterTarget']) != '' && $customRedirectSettings['afterRegister'] == 'yes') { $redirectLink = trim($customRedirectSettings['afterRegisterTarget']); if (wppb_check_missing_http($redirectLink)) { $redirectLink = 'http://' . $redirectLink; } } } } $registerFilterArray['redirectMessage2'] = '<font id="messageTextColor">' . sprintf(__('You will soon be redirected automatically. If you see this page for more than 3 seconds, please click %1$s.%2$s', 'profilebuilder'), '<a href="' . $redirectLink . '">' . __('here', 'profilebuilder') . '</a>', '<meta http-equiv="Refresh" content="3;url=' . $redirectLink . '" />') . '</font><br/><br/>'; echo $registerFilterArray['redirectMessage2'] = apply_filters('wppb_register_redirect_after_creation2', $registerFilterArray['redirectMessage2'], $redirectLink); } if (isset($_POST['send_credentials_via_email'])) { if ($sentEmailStatus == 1) { $registerFilterArray['emailMessage1'] = '<p class="error">' . __('An error occured while trying to send the notification email.', 'profilebuilder') . '</p><!-- .error -->'; $registerFilterArray['emailMessage1'] = apply_filters('wppb_register_send_notification_email_fail', $registerFilterArray['emailMessage1']); echo $registerFilterArray['emailMessage1']; } elseif ($sentEmailStatus == 2) { if ($multisite_message) { $registerFilterArray['wpmuEmailMessage2'] = '<p class="success">' . __('An email containing activation instructions was successfully sent.', 'profilebuilder') . '</p><!-- .success -->'; $registerFilterArray['wpmuEmailMessage2'] = apply_filters('wppb_register_send_notification_email_success', $registerFilterArray['wpmuEmailMessage2']); echo $registerFilterArray['wpmuEmailMessage2']; } else { $registerFilterArray['emailMessage2'] = '<p class="success">' . __('An email containing the username and password was successfully sent.', 'profilebuilder') . '</p><!-- .success -->'; $registerFilterArray['emailMessage2'] = apply_filters('wppb_register_send_notification_email_success', $registerFilterArray['emailMessage2']); echo $registerFilterArray['emailMessage2']; } } } } else { if ($error) { $registerFilterArray['errorMessage'] = '<p class="error">' . $error . '</p><!-- .error -->'; $registerFilterArray['errorMessage'] = apply_filters('wppb_register_error_messaging', $registerFilterArray['errorMessage'], $error); echo $registerFilterArray['errorMessage']; } if (current_user_can('create_users') && $registration) { $registerFilterArray['alertMessage1'] = '<p class="alert">' . __('Users can register themselves or you can manually create users here.', 'profilebuilder') . '</p><!-- .alert -->'; $registerFilterArray['alertMessage1'] = apply_filters('wppb_register_alert_messaging1', $registerFilterArray['alertMessage1']); echo $registerFilterArray['alertMessage1']; } elseif (current_user_can('create_users')) { $registerFilterArray['alertMessage2'] = '<p class="alert">' . __('Users cannot currently register themselves, but you can manually create users here.', 'profilebuilder') . '</p><!-- .alert -->'; $registerFilterArray['alertMessage2'] = apply_filters('wppb_register_alert_messaging2', $registerFilterArray['alertMessage2']); echo $registerFilterArray['alertMessage2']; } elseif (!current_user_can('create_users') && !$registration) { $registerFilterArray['alertMessage3'] = '<p class="alert">' . __('Only an administrator can add new users.', 'profilebuilder') . '</p><!-- .alert -->'; $registerFilterArray['alertMessage3'] = apply_filters('wppb_register_alert_messaging3', $registerFilterArray['alertMessage3']); echo $registerFilterArray['alertMessage3']; } if ($registration || current_user_can('create_users')) { /* use this action hook to add extra content before the register form. */ do_action('wppb_before_register_fields'); ?> <form enctype="multipart/form-data" method="post" id="adduser" class="user-forms" action="http://<?php echo $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?> "> <?php 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 -->'; $registerFilterArray2['name1'] = '<p class="registerNameHeading"><strong>' . __('Name', 'profilebuilder') . '</strong></p>'; $registerFilterArray2['name1'] = apply_filters('wppb_register_content_name1', $registerFilterArray2['name1']); if ($wppb_defaultOptions['username'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['usernameRequired'] == 'yes') { $errorMark = '<font color="red" title="This field is required for registration.">*</font>'; if (isset($_POST['user_name'])) { if (trim($_POST['user_name']) == '') { $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)', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') { if ($wppb_defaultOptions['email'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['emailRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>'; if (isset($_POST['email'])) { if (trim($_POST['email']) == '' || !is_email(trim($_POST['email']))) { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field is required for registration."/>'; $errorVar = ' errorHolder'; } } } $localVar = ''; if (isset($_POST['email'])) { $localVar = $_POST['email']; } $registerFilterArray2['name2'] = ' <p class="form-email' . $errorVar . '"> <label for="email">' . __('E-mail', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="email" type="text" id="email" value="' . trim($localVar) . '" /> </p><!-- .form-email -->'; $registerFilterArray2['name2'] = apply_filters('wppb_register_content_name2_with_email', $registerFilterArray2['name2'], trim($localVar), $errorVar, $errorMark); } } else { $localVar = ''; if (isset($_POST['user_name'])) { $localVar = $_POST['user_name']; } $registerFilterArray2['name2'] = ' <p class="form-username' . $errorVar . '"> <label for="user_name">' . __('Username', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="user_name" type="text" id="user_name" value="' . trim($localVar) . '" /> </p><!-- .form-username -->'; $registerFilterArray2['name2'] = apply_filters('wppb_register_content_name2', $registerFilterArray2['name2'], trim($localVar), $errorVar, $errorMark); } } if ($wppb_defaultOptions['firstname'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['firstnameRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>'; if (isset($_POST['first_name'])) { if (trim($_POST['first_name']) == '') { $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)', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $localVar = ''; if (isset($_POST['first_name'])) { $localVar = $_POST['first_name']; } $registerFilterArray2['name3'] = ' <p class="first_name' . $errorVar . '"> <label for="first_name">' . __('First Name', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="first_name" type="text" id="first_name" value="' . trim($localVar) . '" /> </p><!-- .first_name -->'; $registerFilterArray2['name3'] = apply_filters('wppb_register_content_name3', $registerFilterArray2['name3'], trim($localVar), $errorVar, $errorMark); } if ($wppb_defaultOptions['lastname'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['lastnameRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>'; if (isset($_POST['last_name'])) { if (trim($_POST['last_name']) == '') { $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)', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $localVar = ''; if (isset($_POST['last_name'])) { $localVar = $_POST['last_name']; } $registerFilterArray2['name4'] = ' <p class="last_name' . $errorVar . '"> <label for="last_name">' . __('Last Name', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="last_name" type="text" id="last_name" value="' . trim($localVar) . '" /> </p><!-- .last_name -->'; $registerFilterArray2['name4'] = apply_filters('wppb_register_content_name4', $registerFilterArray2['name4'], trim($localVar), $errorVar, $errorMark); } if ($wppb_defaultOptions['nickname'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['nicknameRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>'; if (isset($_POST['nickname'])) { if (trim($_POST['nickname']) == '') { $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)', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $localVar = ''; if (isset($_POST['nickname'])) { $localVar = $_POST['nickname']; } $registerFilterArray2['name5'] = ' <p class="nickname' . $errorVar . '"> <label for="nickname">' . __('Nickname', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="nickname" type="text" id="nickname" value="' . trim($localVar) . '" /> </p><!-- .nickname -->'; $registerFilterArray2['name5'] = apply_filters('wppb_register_content_name5', $registerFilterArray2['name5'], trim($localVar), $errorVar, $errorMark); } $registerFilterArray2['info1'] = '<p class="registerContactInfoHeading"><strong>' . __('Contact Info', 'profilebuilder') . '</strong></p>'; $registerFilterArray2['info1'] = apply_filters('wppb_register_content_info1', $registerFilterArray2['info1']); if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') { } else { if ($wppb_defaultOptions['email'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['emailRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>'; if (isset($_POST['email'])) { if (trim($_POST['email']) == '' || !is_email(trim($_POST['email']))) { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field is required for registration."/>'; $errorVar = ' errorHolder'; } } } $localVar = ''; if (isset($_POST['email'])) { $localVar = $_POST['email']; } $registerFilterArray2['info2'] = ' <p class="form-email' . $errorVar . '"> <label for="email">' . __('E-mail', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="email" type="text" id="email" value="' . trim($localVar) . '" /> </p><!-- .form-email -->'; $registerFilterArray2['info2'] = apply_filters('wppb_register_content_info2', $registerFilterArray2['info2'], trim($localVar), $errorVar, $errorMark); } } if ($wppb_defaultOptions['website'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['websiteRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>'; if (isset($_POST['website'])) { if (trim($_POST['website']) == '') { $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)', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $localVar = ''; if (isset($_POST['website'])) { $localVar = $_POST['website']; } $registerFilterArray2['info3'] = ' <p class="form-website' . $errorVar . '"> <label for="website">' . __('Website', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="website" type="text" id="website" value="' . trim($localVar) . '" /> </p><!-- .form-website -->'; $registerFilterArray2['info3'] = apply_filters('wppb_register_content_info3', $registerFilterArray2['info3'], trim($localVar), $errorVar, $errorMark); } if ($wppb_defaultOptions['aim'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['aimRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>'; if (isset($_POST['aim'])) { if (trim($_POST['aim']) == '') { $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)', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $localVar = ''; if (isset($_POST['aim'])) { $localVar = $_POST['aim']; } $registerFilterArray2['info4'] = ' <p class="form-aim' . $errorVar . '"> <label for="aim">' . __('AIM', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="aim" type="text" id="aim" value="' . trim($localVar) . '" /> </p><!-- .form-aim -->'; $registerFilterArray2['info4'] = apply_filters('wppb_register_content_info4', $registerFilterArray2['info4'], trim($localVar), $errorVar, $errorMark); } if ($wppb_defaultOptions['yahoo'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['yahooRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>'; if (isset($_POST['yim'])) { if (trim($_POST['yim']) == '') { $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)', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $localVar = ''; if (isset($_POST['yim'])) { $localVar = $_POST['yim']; } $registerFilterArray2['info5'] = ' <p class="form-yim' . $errorVar . '"> <label for="yim">' . __('Yahoo IM', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="yim" type="text" id="yim" value="' . trim($localVar) . '" /> </p><!-- .form-yim -->'; $registerFilterArray2['info5'] = apply_filters('wppb_register_content_info5', $registerFilterArray2['info5'], trim($localVar), $errorVar, $errorMark); } if ($wppb_defaultOptions['jabber'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['jabberRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>'; if (isset($_POST['jabber'])) { if (trim($_POST['jabber']) == '') { $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)', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $localVar = ''; if (isset($_POST['jabber'])) { $localVar = $_POST['jabber']; } $registerFilterArray2['info6'] = ' <p class="form-jabber' . $errorVar . '"> <label for="jabber">' . __('Jabber / Google Talk', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="jabber" type="text" id="jabber" value="' . trim($localVar) . '" /> </p><!-- .form-jabber -->'; $registerFilterArray2['info6'] = apply_filters('wppb_register_content_info6', $registerFilterArray2['info6'], trim($localVar), $errorVar, $errorMark); } $registerFilterArray2['ay1'] = '<p class="registerAboutYourselfHeader"><strong>' . __('About Yourself', 'profilebuilder') . '</strong></p>'; $registerFilterArray2['ay1'] = apply_filters('wppb_register_content_about_yourself1', $registerFilterArray2['ay1']); if ($wppb_defaultOptions['bio'] == 'show') { $errorVar = ''; $errorMark = ''; if ($wppb_defaultOptions['bioRequired'] == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator', 'profilebuilder') . '">*</font>'; if (isset($_POST['description'])) { if (trim($_POST['description']) == '') { $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)', 'profilebuilder') . '"/>'; $errorVar = ' errorHolder'; } } } $localVar = ''; if (isset($_POST['description'])) { $localVar = $_POST['description']; } $registerFilterArray2['ay2'] = ' <p class="form-description' . $errorVar . '"> <label for="description">' . __('Biographical Info', 'profilebuilder') . $errorMark . '</label> <textarea class="text-input" name="description" id="description" rows="5" cols="30">' . trim($localVar) . '</textarea> </p><!-- .form-description -->'; $registerFilterArray2['ay2'] = apply_filters('wppb_register_content_about_yourself2', $registerFilterArray2['ay2'], trim($localVar), $errorVar, $errorMark); } if ($wppb_defaultOptions['password'] == 'show') { $errorMark = ''; $errorMark2 = ''; $errorVar = ''; $errorVar2 = ''; if ($wppb_defaultOptions['passwordRequired'] == 'yes') { $errorMark = '<font color="red" title="This field is required for registration.">*</font>'; $errorMark2 = '<font color="red" title="This field is required for registration.">*</font>'; if (isset($_POST['passw1'])) { if (trim($_POST['passw1']) == '') { $errorMark = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field is required for registration."/>'; $errorVar = ' errorHolder'; } } if (isset($_POST['passw2'])) { if (trim($_POST['passw2']) == '') { $errorMark2 = '<img src="' . WPPB_PLUGIN_URL . '/assets/images/pencil_delete.png" title="This field is required for registration."/>'; $errorVar2 = ' errorHolder'; } } } $localVar1 = ''; if (isset($_POST['passw1'])) { $localVar1 = $_POST['passw1']; } $localVar2 = ''; if (isset($_POST['passw2'])) { $localVar2 = $_POST['passw2']; } $registerFilterArray2['ay3'] = ' <p class="form-password' . $errorVar . '"> <label for="pass1">' . __('Password', 'profilebuilder') . $errorMark . '</label> <input class="text-input" name="passw1" type="password" id="pass1" value="' . trim($localVar1) . '" /> </p><!-- .form-password --> <p class="form-password' . $errorVar2 . '"> <label for="pass2">' . __('Repeat Password', 'profilebuilder') . $errorMark2 . '</label> <input class="text-input" name="passw2" type="password" id="pass2" value="' . trim($localVar2) . '" /> </p><!-- .form-password -->'; $registerFilterArray2['ay3'] = apply_filters('wppb_register_content_about_yourself3', $registerFilterArray2['ay3'], trim($localVar1), trim($localVar2), $errorVar, $errorMark, $errorVar2, $errorMark2); } $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/'; if (file_exists($wppb_premium . 'extra.fields.php')) { require_once $wppb_premium . 'extra.fields.php'; //register_user_extra_fields($error, $_POST, $extraFieldsErrorHolder); $page = 'register'; $returnedValue = wppb_extra_fields($current_user->id, $extraFieldsErrorHolder, $registerFilterArray, $page, $error, $_POST); //copy over extra fields to the rest of the fieldso on the edit profile foreach ($returnedValue as $key => $value) { $registerFilterArray2[$key] = apply_filters('wppb_register_content_' . $key, $value); } } if (function_exists('wppb_add_recaptcha_to_registration_form')) { $wppb_addon_settings = get_option('wppb_addon_settings'); if ($wppb_addon_settings['wppb_reCaptcha'] == 'show') { $reCAPTCHAForm = wppb_add_recaptcha_to_registration_form(); $labelName = apply_filters('wppb_register_anti_spam_title', __('Anti-Spam', 'profilebuilder')); $registerFilterArray2['reCAPTCHAForm'] = '<div class="form-reCAPTCHA"><label class="form-reCAPTCHA-label" for="' . $labelName . '">' . $labelName . '</label>' . $reCAPTCHAForm . '</div><!-- .form-reCAPTCHA -->'; } } // additional filter, just in case it is needed $registerFilterArray2['extraRegistrationFilter'] = ''; $registerFilterArray2['extraRegistrationFilter'] = apply_filters('extraRegistrationField', $registerFilterArray2['extraRegistrationFilter']); // END additional filter, just in case it is needed $wppb_generalSettings = get_option('wppb_general_settings'); if ($wppb_generalSettings['emailConfirmation'] != 'yes') { if (!is_multisite()) { if (isset($_POST['send_credentials_via_email'])) { $checkedVar = ' checked'; } else { $checkedVar = ''; } $registerFilterArray2['confirmationEmailForm'] = ' <p class="send-confirmation-email"> <label for="send-confirmation-email"> <input id="send_credentials_via_email" type="checkbox" name="send_credentials_via_email" value="sending"' . $checkedVar . '/> ' . __('Send these credentials via email.', 'profilebuilder') . ' </label> </p><!-- .send-confirmation-email -->'; $registerFilterArray2['confirmationEmailForm'] = apply_filters('wppb_register_confirmation_email_form', $registerFilterArray2['confirmationEmailForm'], $checkedVar); } } $registerFilterArray2 = apply_filters('wppb_register', $registerFilterArray2); foreach ($registerFilterArray2 as $key => $value) { echo $value; } ?> <p class="form-submit"> <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'); } ?> " /> <input name="action" type="hidden" id="action" value="adduser" /> <input type="hidden" name="formName" value="register" /> </p><!-- .form-submit --> <?php wp_nonce_field('verify_true_registration', 'register_nonce_field'); ?> </form><!-- #adduser --> <?php } } /* use this action hook to add extra content after the register form. */ do_action('wppb_after_register_fields'); ?> </div> <?php $output = ob_get_contents(); ob_end_clean(); return $output; }
function wppb_add_meta_to_user_on_activation($user_id, $password, $meta) { $user = new WP_User($user_id); //copy the data from the meta field (default fields) if (!empty($meta['first_name'])) { update_user_meta($user_id, 'first_name', $meta['first_name']); } if (!empty($meta['last_name'])) { update_user_meta($user_id, 'last_name', $meta['last_name']); } if (!empty($meta['nickname'])) { update_user_meta($user_id, 'nickname', $meta['nickname']); } if (!empty($meta['user_url'])) { update_user_meta($user_id, 'user_url', $meta['user_url']); } if (!empty($meta['aim'])) { update_user_meta($user_id, 'aim', $meta['aim']); } if (!empty($meta['yim'])) { update_user_meta($user_id, 'yim', $meta['yim']); } if (!empty($meta['jabber'])) { update_user_meta($user_id, 'jabber', $meta['jabber']); } if (!empty($meta['description'])) { update_user_meta($user_id, 'description', $meta['description']); } if (!empty($meta['role'])) { $user->set_role($meta['role']); } //update the users role (s)he registered for //copy the data from the meta fields (custom fields) $manage_fields = get_option('wppb_manage_fields', 'not_set'); if ($manage_fields != 'not_set') { foreach ($manage_fields as $key => $value) { switch ($value['field']) { case 'Input': if (isset($meta[$value['meta-name']])) { update_user_meta($user_id, $value['meta-name'], trim($meta[$value['meta-name']])); } break; case 'Input (Hidden)': if (isset($meta[$value['meta-name']])) { update_user_meta($user_id, $value['meta-name'], trim($meta[$value['meta-name']])); } break; case 'Checkbox': if (isset($meta[$value['meta-name']])) { update_user_meta($user_id, $value['meta-name'], trim($meta[$value['meta-name']])); } break; case 'Checkbox (Terms and Conditions)': if (isset($meta[$value['meta-name']])) { update_user_meta($user_id, $value['meta-name'], trim($meta[$value['meta-name']])); } break; case 'Radio': if (isset($meta[$value['meta-name']])) { update_user_meta($user_id, $value['meta-name'], trim($meta[$value['meta-name']])); } break; case 'Select': if (isset($meta[$value['meta-name']])) { update_user_meta($user_id, $value['meta-name'], trim($meta[$value['meta-name']])); } break; case 'Select (Country)': if (isset($meta[$value['meta-name']])) { update_user_meta($user_id, $value['meta-name'], trim($meta[$value['meta-name']])); } break; case 'Select (Multiple)': if (isset($meta[$value['meta-name']])) { update_user_meta($user_id, $value['meta-name'], trim($meta[$value['meta-name']])); } break; case 'Select (Timezone)': if (isset($meta[$value['meta-name']])) { update_user_meta($user_id, $value['meta-name'], trim($meta[$value['meta-name']])); } break; case 'Datepicker': if (isset($meta[$value['meta-name']])) { update_user_meta($user_id, $value['meta-name'], trim($meta[$value['meta-name']])); } break; case 'Textarea': if (isset($meta[$value['meta-name']])) { update_user_meta($user_id, $value['meta-name'], trim($meta[$value['meta-name']])); } break; case 'Upload': if (isset($meta[$value['meta-name']])) { $wp_upload_array = wp_upload_dir(); // Array of key => value pairs $file = trim($meta[$value['meta-name']]); $file_name = substr($file, strpos($file, '_attachment_') + 12); $random_user_number = apply_filters('wppb_register_wpmu_upload_random_user_number2', substr(md5($user->data->user_email), 0, 12), $user, $meta); $old_path_on_disk = $wp_upload_array['basedir'] . '/profile_builder/attachments/' . substr($file, strpos($file, 'wpmuRandomID_')); if (PHP_OS == "WIN32" || PHP_OS == "WINNT") { $old_path_on_disk = str_replace('\\', '/', $old_path_on_disk); } $new_path_on_disk = $wp_upload_array['basedir'] . '/profile_builder/attachments/userID_' . $user_id . '_attachment_' . $file_name; if (PHP_OS == "WIN32" || PHP_OS == "WINNT") { $new_path_on_disk = str_replace('\\', '/', $new_path_on_disk); } if (rename($old_path_on_disk, $new_path_on_disk)) { update_user_meta($user_id, $value['meta-name'], $wp_upload_array['baseurl'] . '/profile_builder/attachments/userID_' . $user_id . '_attachment_' . $file_name); } } break; case 'Avatar': if (isset($meta[$value['meta-name']])) { $wp_upload_array = wp_upload_dir(); // Array of key => value pairs $file = trim($meta[$value['meta-name']]); $file_name = substr($file, strpos($file, '_originalAvatar_') + 16); $random_user_number = apply_filters('wppb_register_wpmu_avatar_random_user_number2', substr(md5($user->data->user_email), 0, 12), $user, $meta); $old_path_on_disk = $wp_upload_array['basedir'] . '/profile_builder/avatars/' . substr($file, strpos($file, 'wpmuRandomID_')); if (PHP_OS == "WIN32" || PHP_OS == "WINNT") { $old_path_on_disk = str_replace('\\', '/', $old_path_on_disk); } $new_path_on_disk = $wp_upload_array['basedir'] . '/profile_builder/avatars/userID_' . $user_id . '_originalAvatar_' . $file_name; if (PHP_OS == "WIN32" || PHP_OS == "WINNT") { $new_path_on_disk = str_replace('\\', '/', $new_path_on_disk); } if (rename($old_path_on_disk, $new_path_on_disk)) { $wp_filetype = wp_check_filetype(basename($file_name), null); $attachment = array('post_mime_type' => $wp_filetype['type'], 'post_title' => $file_name, 'post_content' => '', 'post_status' => 'inherit'); $attach_id = wp_insert_attachment($attachment, $new_path_on_disk); $avatar = image_downsize($attach_id, 'thumbnail'); update_user_meta($user_id, $value['meta-name'], $avatar[0]); update_user_meta($user_id, 'avatar_directory_path_' . $value['id'], $new_path_on_disk); update_user_meta($user_id, 'resized_avatar_' . $value['id'] . '_relative_path', $new_path_on_disk); wppb_resize_avatar($user_id); } } break; } } } }
function wppb_add_meta_to_user_on_activation($user_id, $password, $meta) { //copy the data from the meta field (default fields) if (!empty($meta['first_name'])) { update_user_meta($user_id, 'first_name', $meta['first_name']); } if (!empty($meta['last_name'])) { update_user_meta($user_id, 'last_name', $meta['last_name']); } if (!empty($meta['nickname'])) { update_user_meta($user_id, 'nickname', $meta['nickname']); } if (!empty($meta['user_url'])) { update_user_meta($user_id, 'user_url', $meta['user_url']); } if (!empty($meta['aim'])) { update_user_meta($user_id, 'aim', $meta['aim']); } if (!empty($meta['yim'])) { update_user_meta($user_id, 'yim', $meta['yim']); } if (!empty($meta['jabber'])) { update_user_meta($user_id, 'jabber', $meta['jabber']); } if (!empty($meta['description'])) { update_user_meta($user_id, 'description', $meta['description']); } //update the users role (s)he registered for if (!empty($meta['role'])) { $user = new WP_User($user_id); $user->set_role($meta['role']); } //copy the data from the meta fields (custom fields) $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/'; if (file_exists($wppb_premium . 'extra.fields.php')) { $wppbFetchArray = get_option('wppb_custom_fields'); foreach ($wppbFetchArray as $key => $value) { switch ($value['item_type']) { case "input": if (!empty($meta[$value['item_type'] . $value['id']])) { update_user_meta($user_id, $value['item_metaName'], $meta[$value['item_type'] . $value['id']]); } break; case "hiddenInput": if (!empty($meta[$value['item_type'] . $value['id']])) { update_user_meta($user_id, $value['item_metaName'], $meta[$value['item_type'] . $value['id']]); } break; case "checkbox": if (!empty($meta[$value['item_type'] . $value['id']])) { update_user_meta($user_id, $value['item_metaName'], $meta[$value['item_type'] . $value['id']]); } break; case "radio": if (!empty($meta[$value['item_type'] . $value['id']])) { update_user_meta($user_id, $value['item_metaName'], $meta[$value['item_type'] . $value['id']]); } break; case "select": if (!empty($meta[$value['item_type'] . $value['id']])) { update_user_meta($user_id, $value['item_metaName'], $meta[$value['item_type'] . $value['id']]); } break; case "countrySelect": if (!empty($meta[$value['item_type'] . $value['id']])) { update_user_meta($user_id, $value['item_metaName'], $meta[$value['item_type'] . $value['id']]); } break; case "timeZone": if (!empty($meta[$value['item_type'] . $value['id']])) { update_user_meta($user_id, $value['item_metaName'], $meta[$value['item_type'] . $value['id']]); } break; case "datepicker": if (!empty($meta[$value['item_type'] . $value['id']])) { update_user_meta($user_id, $value['item_metaName'], $meta[$value['item_type'] . $value['id']]); } break; case "textarea": if (!empty($meta[$value['item_type'] . $value['id']])) { update_user_meta($user_id, $value['item_metaName'], $meta[$value['item_type'] . $value['id']]); } break; case "upload": if (!empty($meta[$value['item_type'] . $value['id']])) { $filename = $meta[$value['item_type'] . $value['id']]; $fileNameStartUpload = strpos((string) $filename, '_attachment_'); $originalUploadFilename = substr($filename, $fileNameStartUpload + 12); $newFileName = 'userID_' . $user_id . '_attachment_' . $originalUploadFilename; $wpUploadPath = wp_upload_dir(); // Array of key => value pairs $target_path_original = $wpUploadPath['baseurl'] . "/profile_builder/attachments/"; $fileDir = $wpUploadPath['basedir'] . '/profile_builder/attachments/'; $target_path = $target_path_original . 'userID_' . $user_id . '_attachment_' . $originalUploadFilename; $renamedVar = rename($fileDir . $meta[$value['item_type'] . $value['id']], $fileDir . $newFileName); if ($renamedVar) { add_user_meta($user_id, $value['item_metaName'], $target_path); } } break; case "avatar": if (!empty($meta[$value['item_type'] . $value['id']])) { $filename = $meta[$value['item_type'] . $value['id']]; $fileNameStartAvatar = strpos((string) $filename, 'originalAvatar_'); $originalAvatarFilename = substr($filename, $fileNameStartAvatar + 15); $newFileName = 'userID_' . $user_id . '_originalAvatar_' . $originalAvatarFilename; $wpUploadPath = wp_upload_dir(); // Array of key => value pairs $target_path_original = $wpUploadPath['baseurl'] . "/profile_builder/avatars/"; $fileDir = $wpUploadPath['basedir'] . '/profile_builder/avatars/'; $target_path = $target_path_original . 'userID_' . $user_id . '_originalAvatar_' . $originalAvatarFilename; $renamedVar = rename($fileDir . 'wpmuRandomID_' . $meta[$value['item_type'] . $value['id'] . '_radomUserNumber'] . '_originalAvatar_' . $originalAvatarFilename, $fileDir . $newFileName); if ($renamedVar) { $wp_filetype = wp_check_filetype(basename($filename), null); $attachment = array('post_mime_type' => $wp_filetype['type'], 'post_title' => $filename, 'post_content' => '', 'post_status' => 'inherit'); $attach_id = wp_insert_attachment($attachment, $target_path); $upFile = image_downsize($attach_id, 'thumbnail'); $upFile = $upFile[0]; add_user_meta($user_id, $value['item_metaName'], $upFile); wppb_resize_avatar($user_id); } } break; } } } }
function wppb_decode_extraTag($tagName) { //filter to get current user by either username or id(default); get user by username? $userlistingFilterArray['getUserByID'] = false; $userlistingFilterArray['getUserByID'] = apply_filters('wppb_userlisting_get_user_by_id', $userlistingFilterArray['getUserByID']); //get user ID if (isset($_GET['userID'])) { $user = get_userdata($_GET['userID']); $username = $user->user_login; } else { if ($userlistingFilterArray['getUserByID'] === false) { $userID = get_query_var('username'); $user = get_userdata($userID); $username = $user->user_login; } else { $username = get_query_var('username'); } } $user = get_user_by('login', $username); if ($user->ID == null) { return ''; } if ($tagName == 'extra_go_back_link') { $textLink2 = apply_filters('wppb_userlisting_go_back_link_type', true); if ($textLink2) { return $userlistingFilterArray['backLink1'] = apply_filters('wppb_userlisting_go_back_link', '<div id="wppb-back-span" class="wppb-back-span"><a href=\'javascript:history.go(-1)\' class="wppb-back" id="wppb-back" title="' . __('Click here to go back', 'profilebuilder') . '" alt="' . __('Back', 'profilebuilder') . '">' . __('Back', 'profilebuilder') . '</a></div>'); } else { return $userlistingFilterArray['backLink2'] = apply_filters('wppb_userlisting_go_back_link_with_arrow', '<a href=\'javascript:history.go(-1)\' class="wppb-back"><img src="' . WPPB_PLUGIN_URL . '/assets/images/arrow_left.png" title="' . __('Click here to go back', 'profilebuilder') . '" alt="<"/></a>'); } } elseif ($tagName == 'extra_avatar_or_gravatar') { $customUserListingSettings = get_option('customUserListingSettings', 'not_found'); $avatarSizeSingle = apply_filters('wppb_userlisting_avatar_size_single_userlisting', $customUserListingSettings['avatarSizeSingle']); $avatarImage = get_avatar($user->ID, $avatarSize); return $userData = apply_filters('wppb_userlisting_extra_avatar_or_gravatar_single_userlisting', $avatarImage, $user, $avatarSizeSingle); } elseif ($tagName == 'meta_user_name') { $userData = get_the_author_meta('user_login', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_user_name', $userData, $user); } elseif ($tagName == 'meta_email') { $userData = get_the_author_meta('user_email', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_email', $userData, $user); } elseif ($tagName == 'meta_first_name') { $userData = get_the_author_meta('first_name', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_first_name', $userData, $user); } elseif ($tagName == 'meta_first_last_name') { $userData1 = get_the_author_meta('first_name', $user->ID); $userData2 = get_the_author_meta('last_name', $user->ID); if ($userData1 != '' && $userData2 != '') { $userData = $userData1 . ' ' . $userData2; } elseif ($userData1 == '') { $userData = $userData2; } elseif ($userData2 == '') { $userData = $userData1; } else { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_first_last_name_single_userlisting', $userData, $user); } elseif ($tagName == 'meta_last_name') { $userData = get_the_author_meta('last_name', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_last_name', $userData, $user); } elseif ($tagName == 'meta_nickname') { $userData = get_the_author_meta('nickname', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_nickname', $userData, $user); } elseif ($tagName == 'meta_display_name') { $userData = get_the_author_meta('display_name', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_display_name', $userData, $user); } elseif ($tagName == 'meta_number_of_posts') { $args = array('author' => $user->ID, 'numberposts' => -1); $allPosts = get_posts($args); $postsNumber = count($allPosts); return $userData = apply_filters('wppb_userlisting_extra_meta_number_of_posts_single_userlisting', '<a href="' . get_author_posts_url($user->ID) . '" id="postNumberLinkSingle" class="postNumberLinkSingle">' . $postsNumber . '</a>', $user, $postsNumber); } elseif ($tagName == 'meta_website') { $userData = get_the_author_meta('user_url', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_website', $userData, $user); } elseif ($tagName == 'meta_aim') { $userData = get_the_author_meta('aim', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_aim', $userData, $user); } elseif ($tagName == 'meta_yim') { $userData = get_the_author_meta('yim', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_yim', $userData, $user); } elseif ($tagName == 'meta_jabber') { $userData = get_the_author_meta('jabber', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_jabber', $userData, $user); } elseif ($tagName == 'meta_role') { if (isset($GLOBALS['wp_roles']->roles[$user->roles[0]])) { $role = $GLOBALS['wp_roles']->roles[$user->roles[0]]['name']; } else { $role = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_role_single_userlisting', $role, $user); } elseif ($tagName == 'meta_biographical_info') { $userData = get_the_author_meta('description', $user->ID); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_biographical_info', $userData, $user); } elseif ($tagName == 'meta_registration_date') { $time = date("n/j/Y", strtotime($user->user_registered)); return $userData = apply_filters('wppb_userlisting_extra_meta_tag_registration_date', $time, $user); } else { global $wppbFetchArray; if (count($wppbFetchArray) >= 1) { foreach ($wppbFetchArray as $key => $value) { if ('meta_' . $value['item_metaName'] == $tagName) { switch ($value['item_type']) { case "input": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_metaName'], $userData, $user); case "checkbox": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData != '') { $userDataArray = explode(',', $userData); $value['item_options'] = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $id . '_options_translation', $value['item_options']); $newValue = str_replace(' ', '#@space@#', $value['item_options']); //we need to escape the spaces in the options list, because it won't save $checkboxValue = explode(',', $value['item_options']); $checkboxValue2 = explode(',', $newValue); $nr = count($userDataArray); $userData = ''; for ($i = 0; $i < $nr - 2; $i++) { $userData .= $userDataArray[$i] . ', '; } $userData .= $userDataArray[$nr - 2]; } else { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_metaName'], $userData, $user); case "radio": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_metaName'], $userData, $user); case "select": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_metaName'], $userData, $user); case "countrySelect": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_metaName'], $userData, $user); case "timeZone": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_metaName'], $userData, $user); case "datepicker": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_metaName'], $userData, $user); case "textarea": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData != '') { $userData = nl2br($userData); } else { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_metaName'], $userData, $user); case "upload": $imgSource = WPPB_PLUGIN_URL . '/assets/images/'; $script = WPPB_PLUGIN_URL . '/premium/functions/'; $userData = get_user_meta($user->ID, $value['item_metaName'], true); $fileName = str_replace(get_bloginfo('home') . '/wp-content/uploads/profile_builder/attachments/userID_' . $user->ID . '_attachment_', '', $userData); if ($userData == '' || $userData == get_bloginfo('url') . '/wp-content/uploads/profile_builder/attachments/') { $retUserData = '<span class="wppb-description-delimiter2"><u>' . __('Current file', 'profilebuilder') . '</u>: </span><span class="wppb-description-delimiter2">' . __('No uploaded attachment', 'profilebuilder') . '</span>'; } else { $retUserData = '<span class="wppb-description-delimiter2"><u>' . __('Current file', 'profilebuilder') . '</u>: ' . $fileName . '<a href="' . $userData . '" target="_blank" class="wppb-cattachment"><img src="' . $imgSource . 'attachment.png" title="' . __('Click to see the current attachment', 'profilebuilder') . '"></a></span>'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_metaName'], $retUserData, $user); case "avatar": $imgSource = WPPB_PLUGIN_URL . '/assets/images/'; $userData = get_user_meta($user->ID, $value['item_metaName'], true); // to use for the link $userData2 = get_user_meta($user->ID, 'resized_avatar_' . $value['id'], true); //to use for the preview //this checks if it only has 1 component if (is_numeric($value['item_options'])) { $width = $height = $value['item_options']; //this checks if the entered value has 2 components } else { $sentValue = explode(',', $value['item_options']); $width = $sentValue[0]; $height = $sentValue[1]; } if ($userData != '') { if ($userData2 == '') { wppb_resize_avatar($user->ID); $userData2 = get_user_meta($user->ID, 'resized_avatar_' . $value['id'], true); //to use for the preview } $imgRelativePath = get_user_meta($user->ID, 'resized_avatar_' . $value['id'] . '_relative_path', true); //get relative path //get image info $info = getimagesize($imgRelativePath); //this checks if it only has 1 component if (is_numeric($item_options)) { $width = $height = $item_options; //this checks if the entered value has 2 components } else { $sentValue = explode(',', $item_options); $width = $sentValue[0]; $height = $sentValue[1]; } //call the avatar resize function if needed if ($info[0] != $width || $info[1] != $height) { wppb_resize_avatar($user->ID); //re-fetch user-data $userData2 = get_user_meta($user->ID, 'resized_avatar_' . $value['id'], true); //to use for the preview } if ($userData == '' || $userData == get_bloginfo('url') . '/wp-content/uploads/profile_builder/avatars/') { return $avatarImage = get_avatar($user->ID, $value['item_options']); } else { // display the resized image $retUserData = '<span class="avatar-border"><IMG SRC="' . $userData2 . '" TITLE="' . __('Avatar', 'profilebuilder') . '" ALT="' . __('Avatar', 'profilebuilder') . '" HEIGHT=' . $info[1] . ' WIDTH=' . $info[0] . '></span>'; // display a link to the bigger image to see it clearly return $retUserData .= '<a href="' . $userData . '" target="_blank" class="wppb-cattachment"><img src="' . $imgSource . 'attachment.png" title="' . __('Click to see the current attachment', 'profilebuilder') . '"></a>'; } } else { return $avatarImage = get_avatar($user->ID, $width); } } } elseif ('meta_description_' . $value['item_metaName'] == $tagName) { return $value['item_desc']; } elseif ('meta_' . $value['item_metaName'] . '_URL' == $tagName) { switch ($value['item_type']) { case "upload": $userData = get_user_meta($user->ID, $value['item_metaName'], true); $fileName = str_replace(get_bloginfo('home') . '/wp-content/uploads/profile_builder/attachments/userID_' . $user->ID . '_attachment_', '', $userData); if ($userData == '' || $userData == get_bloginfo('url') . '/wp-content/uploads/profile_builder/attachments/') { return $userData = apply_filters('wppb_userlisting_extra_meta_' . $value['item_metaName'] . '_url_empty_single', $userData, $object); } else { return $userData = apply_filters('wppb_userlisting_extra_meta_' . $value['item_metaName'] . '_url_single', $userData, $object); } } } elseif ('meta_' . $value['item_title'] == $tagName) { //fall-back switch ($value['item_type']) { case "input": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_title'], $userData, $user); case "checkbox": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData != '') { $userDataArray = explode(',', $userData); $value['item_options'] = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $id . '_options_translation', $value['item_options']); $newValue = str_replace(' ', '#@space@#', $value['item_options']); //we need to escape the spaces in the options list, because it won't save $checkboxValue = explode(',', $value['item_options']); $checkboxValue2 = explode(',', $newValue); $nr = count($userDataArray); $userData = ''; for ($i = 0; $i < $nr - 2; $i++) { $userData .= $userDataArray[$i] . ', '; } $userData .= $userDataArray[$nr - 2]; } else { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_title'], $userData, $user); case "radio": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_title'], $userData, $user); case "select": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_title'], $userData, $user); case "countrySelect": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_title'], $userData, $user); case "timeZone": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_title'], $userData, $user); case "datepicker": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData == '') { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_title'], $userData, $user); case "textarea": $userData = get_user_meta($user->ID, $value['item_metaName'], true); if ($userData != '') { $userData = nl2br($userData); } else { $userData = '-'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_title'], $userData, $user); case "upload": $imgSource = WPPB_PLUGIN_URL . '/assets/images/'; $script = WPPB_PLUGIN_URL . '/premium/functions/'; $userData = get_user_meta($user->ID, $value['item_metaName'], true); $fileName = str_replace(get_bloginfo('home') . '/wp-content/uploads/profile_builder/attachments/userID_' . $user->ID . '_attachment_', '', $userData); if ($userData == '' || $userData == get_bloginfo('url') . '/wp-content/uploads/profile_builder/attachments/') { $retUserData = '<span class="wppb-description-delimiter2"><u>' . __('Current file', 'profilebuilder') . '</u>: </span><span class="wppb-description-delimiter2">' . __('No uploaded attachment', 'profilebuilder') . '</span>'; } else { $retUserData = '<span class="wppb-description-delimiter2"><u>' . __('Current file', 'profilebuilder') . '</u>: ' . $fileName . '<a href="' . $userData . '" target="_blank" class="wppb-cattachment"><img src="' . $imgSource . 'attachment.png" title="' . __('Click to see the current attachment', 'profilebuilder') . '"></a></span>'; } return $userData = apply_filters('wppb_userlisting_extra_meta_tag_' . $value['item_title'], $retUserData, $user); case "avatar": $imgSource = WPPB_PLUGIN_URL . '/assets/images/'; $userData = get_user_meta($user->ID, $value['item_metaName'], true); // to use for the link $userData2 = get_user_meta($user->ID, 'resized_avatar_' . $value['id'], true); //to use for the preview //this checks if it only has 1 component if (is_numeric($value['item_options'])) { $width = $height = $value['item_options']; //this checks if the entered value has 2 components } else { $sentValue = explode(',', $value['item_options']); $width = $sentValue[0]; $height = $sentValue[1]; } if ($userData != '') { if ($userData2 == '') { wppb_resize_avatar($user->ID); $userData2 = get_user_meta($user->ID, 'resized_avatar_' . $value['id'], true); //to use for the preview } $imgRelativePath = get_user_meta($user->ID, 'resized_avatar_' . $value['id'] . '_relative_path', true); //get relative path //get image info $info = getimagesize($imgRelativePath); //this checks if it only has 1 component if (is_numeric($item_options)) { $width = $height = $item_options; //this checks if the entered value has 2 components } else { $sentValue = explode(',', $item_options); $width = $sentValue[0]; $height = $sentValue[1]; } //call the avatar resize function if needed if ($info[0] != $width || $info[1] != $height) { wppb_resize_avatar($user->ID); //re-fetch user-data $userData2 = get_user_meta($user->ID, 'resized_avatar_' . $value['id'], true); //to use for the preview } if ($userData == '' || $userData == get_bloginfo('url') . '/wp-content/uploads/profile_builder/avatars/') { return $avatarImage = get_avatar($user->ID, $value['item_options']); } else { // display the resized image $retUserData = '<span class="avatar-border"><IMG SRC="' . $userData2 . '" TITLE="' . __('Avatar', 'profilebuilder') . '" ALT="' . __('Avatar', 'profilebuilder') . '" HEIGHT=' . $info[1] . ' WIDTH=' . $info[0] . '></span>'; // display a link to the bigger image to see it clearly return $retUserData .= '<a href="' . $userData . '" target="_blank" class="wppb-cattachment"><img src="' . $imgSource . 'attachment.png" title="' . __('Click to see the current attachment', 'profilebuilder') . '"></a>'; } } else { return $avatarImage = get_avatar($user->ID, $width); } } } elseif ('meta_description_' . $value['item_title'] == $tagName) { return $value['item_desc']; } } } } }
function wppb_add_meta_to_user_on_activation($user_id, $password, $meta) { //copy the data from the meta field (default fields) if (!empty($meta['first_name'])) { update_user_meta($user_id, 'first_name', $meta['first_name']); } if (!empty($meta['last_name'])) { update_user_meta($user_id, 'last_name', $meta['last_name']); } if (!empty($meta['nickname'])) { update_user_meta($user_id, 'nickname', $meta['nickname']); } if (!empty($meta['user_url'])) { update_user_meta($user_id, 'user_url', $meta['user_url']); } if (!empty($meta['aim'])) { update_user_meta($user_id, 'aim', $meta['aim']); } if (!empty($meta['yim'])) { update_user_meta($user_id, 'yim', $meta['yim']); } if (!empty($meta['jabber'])) { update_user_meta($user_id, 'jabber', $meta['jabber']); } if (!empty($meta['description'])) { update_user_meta($user_id, 'description', $meta['description']); } //update the users role (s)he registered for if (!empty($meta['role'])) { $user = new WP_User($user_id); $user->set_role($meta['role']); } //copy the data from the meta fields (custom fields) $wppb_premium = WPPB_PLUGIN_DIR . '/premium/functions/'; if (file_exists($wppb_premium . 'extra.fields.php')) { $wppbFetchArray = get_option('wppb_custom_fields'); foreach ($wppbFetchArray as $key => $value) { switch ($value['item_type']) { case "input": if (!empty($meta[$value['item_type'] . $value['id']])) { update_user_meta($user_id, $value['item_metaName'], $meta[$value['item_type'] . $value['id']]); } break; case "hiddenInput": if (!empty($meta[$value['item_type'] . $value['id']])) { update_user_meta($user_id, $value['item_metaName'], $meta[$value['item_type'] . $value['id']]); } break; case "checkbox": if (!empty($meta[$value['item_type'] . $value['id']])) { update_user_meta($user_id, $value['item_metaName'], $meta[$value['item_type'] . $value['id']]); } break; case "radio": if (!empty($meta[$value['item_type'] . $value['id']])) { update_user_meta($user_id, $value['item_metaName'], $meta[$value['item_type'] . $value['id']]); } break; case "select": if (!empty($meta[$value['item_type'] . $value['id']])) { update_user_meta($user_id, $value['item_metaName'], $meta[$value['item_type'] . $value['id']]); } break; case "countrySelect": if (!empty($meta[$value['item_type'] . $value['id']])) { update_user_meta($user_id, $value['item_metaName'], $meta[$value['item_type'] . $value['id']]); } break; case "timeZone": if (!empty($meta[$value['item_type'] . $value['id']])) { update_user_meta($user_id, $value['item_metaName'], $meta[$value['item_type'] . $value['id']]); } break; case "datepicker": if (!empty($meta[$value['item_type'] . $value['id']])) { update_user_meta($user_id, $value['item_metaName'], $meta[$value['item_type'] . $value['id']]); } break; case "textarea": if (!empty($meta[$value['item_type'] . $value['id']])) { update_user_meta($user_id, $value['item_metaName'], $meta[$value['item_type'] . $value['id']]); } break; case "upload": if (!empty($meta[$value['item_type'] . $value['id']])) { $uploaded_file_with_path = $meta[$value['item_type'] . $value['id']]; $original_filename = substr($uploaded_file_with_path, strpos($uploaded_file_with_path, '_attachment_') + 12); $wp_upload_array = wp_upload_dir(); // Array of key => value pairs $old_path_on_disk = $wp_upload_array['basedir'] . '/profile_builder/attachments/' . substr($uploaded_file_with_path, strpos($uploaded_file_with_path, 'wpmuRandomID_')); $new_path_on_disk = $wp_upload_array['basedir'] . '/profile_builder/attachments/userID_' . $user_id . '_attachment_' . $original_filename; if (rename($old_path_on_disk, $new_path_on_disk)) { add_user_meta($user_id, $value['item_metaName'], $wp_upload_array['baseurl'] . '/profile_builder/attachments/userID_' . $user_id . '_attachment_' . $original_filename); } } break; case "avatar": if (!empty($meta[$value['item_type'] . $value['id']])) { $wp_upload_array = wp_upload_dir(); // Array of key => value pairs $file_name = str_replace($wp_upload_array['baseurl'] . '/profile_builder/avatars/wpmuRandomID_' . $meta[$value['item_type'] . $value['id'] . '_radomUserNumber'] . '_originalAvatar_', '', $meta[$value['item_type'] . $value['id']]); $new_file_dir_path = $wp_upload_array['basedir'] . '/profile_builder/avatars/userID_' . $user_id . '_originalAvatar_' . $file_name; if (PHP_OS == "WIN32" || PHP_OS == "WINNT") { $new_file_dir_path = str_replace('\\', '/', $new_file_dir_path); } $renamed = rename(str_replace($wp_upload_array['baseurl'], $wp_upload_array['basedir'], $meta[$value['item_type'] . $value['id']]), $new_file_dir_path); if ($renamed) { $wp_filetype = wp_check_filetype(basename($file_name), null); $attachment = array('post_mime_type' => $wp_filetype['type'], 'post_title' => $file_name, 'post_content' => '', 'post_status' => 'inherit'); $attach_id = wp_insert_attachment($attachment, $new_file_dir_path); $upFile = image_downsize($attach_id, 'thumbnail'); $upFile = $upFile[0]; add_user_meta($user_id, $value['item_metaName'], $upFile); add_user_meta($user_id, 'avatar_directory_path_' . $value['id'], $new_file_dir_path); add_user_meta($user_id, 'resized_avatar_' . $value['id'] . '_relative_path', $new_file_dir_path); wppb_resize_avatar($user_id); } } break; } } } }
function wppb_avatar_handler($page, $item_title, $id, $item_desc, $item_required, $item_type, $currentUser, $filterArray, $extraFieldsErrorHolder, $postData, $item_options, $error, $fieldName) { $item_title = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $id . '_title_translation', $item_title); $item_desc = wppb_icl_t('plugin profile-builder-pro', 'custom_field_' . $id . '_description_translation', $item_desc); //add the nonce field $wppb_nonce = wp_create_nonce('user' . $currentUser . '_nonce_avatar'); $imgSource = WPPB_PLUGIN_URL . '/assets/images/'; /* get the needed userdatas */ $userData = get_user_meta($currentUser, $fieldName, true); // to use for the link $userData2 = get_user_meta($currentUser, 'resized_avatar_' . $id, true); //to use for the preview if ($userData != '') { if ($userData2 == '') { wppb_resize_avatar($currentUser); $userData2 = get_user_meta($currentUser, 'resized_avatar_' . $id, true); //to use for the preview } //get image info $imgRelativePath = get_user_meta($currentUser, 'resized_avatar_' . $id . '_relative_path', true); //get relative path $info = getimagesize($imgRelativePath); //this checks if it only has 1 component if (is_numeric($item_options)) { $width = $height = $item_options; //this checks if the entered value has 2 components } else { $sentValue = explode(',', $item_options); $width = $sentValue[0]; $height = $sentValue[1]; } //call the avatar resize function if needed if ($info[0] != $width || $info[1] != $height) { wppb_resize_avatar($currentUser); //re-fetch user-data $userData2 = get_user_meta($currentUser, 'resized_avatar_' . $id, true); } } $wpUploadPath = wp_upload_dir(); // Array of key => value pairs $fileName = str_replace($wpUploadPath['baseurl'] . '/profile_builder/attachments/userID_' . $currentUser . '_attachment_', '', $userData); if ($page == 'back_end') { $filterArray['avatarCustomField'] = ' <table class="form-table"> <tr> <th><label for="' . $item_type . $id . '">' . $item_title . '</label></th> <td> <input name="' . $item_type . $id . '" id="' . $item_type . $id . '" size="40" type="file" /><font color="grey" size="1">(' . __('max upload size', 'profilebuilder') . ' ' . WPPB_SERVER_MAX_UPLOAD_SIZE_MEGA . 'b)</font> <br/><span class="wppb-description-delimiter">' . $item_desc; if ($userData == '' || $userData == get_bloginfo('url') . '/wp-content/uploads/profile_builder/avatars/') { $filterArray['avatarCustomField'] .= '</span><br/><span class="wppb-description-delimiter"><u>' . __('Current avatar', 'profilebuilder') . '</u>: </span><span style="padding-left:5px"></span><span class="wppb-description-delimiter"><i>' . __('No uploaded avatar', 'profilebuilder') . '</i></span>'; } else { /* display the resized image*/ $filterArray['avatarCustomField'] .= '<br/><span class="avatar-border"><IMG SRC="' . $userData2 . '" TITLE="' . __('Avatar', 'profilebuilder') . '" ALT="' . __('Avatar', 'profilebuilder') . '" HEIGHT=' . $info[1] . ' WIDTH=' . $info[0] . '></span>'; /* display a link to the bigger image to see it clearly and a delete icon*/ $text = __('Are you sure you want to delete this avatar?', 'profilebuilder'); $filterArray['avatarCustomField'] .= '<span style="padding-left:10px"></span><span style="padding-left:5px"></span><a href="' . $userData . '" target="_blank"><img src="' . $imgSource . 'attachment.png" title="' . __('Click to see the current attachment', 'profilebuilder') . '"></a><span style="padding-left:15px"></span><a href="javascript:confirmDelete(\'' . $wppb_nonce . '\',\'' . $currentUser . '\',\'' . $id . '\',\'' . $fieldName . '\',\'' . get_permalink() . '\',\'' . get_bloginfo('url') . '/wp-admin/admin-ajax.php\',\'avatar\',\'' . $text . '\')"><img src="' . $imgSource . 'icon_delete.png" title="' . __('Click to delete the current attachment', 'profilebuilder') . '"></a>'; } $filterArray['avatarCustomField'] .= ' </td> </tr> </table>'; $filterArray['avatarCustomField'] = apply_filters('wppb_' . $page . '_avatar_custom_field_' . $id, $filterArray['avatarCustomField'], $userData, $userData2, $item_title, $id, $item_desc); } else { $errorVar = ''; $errorMark = ''; if (isset($item_required)) { if ($item_required == 'yes') { $errorMark = '<font color="red" title="' . __('This field is marked as required by the administrator.', 'profilebuilder') . '">*</font>'; } } if (in_array($id, $extraFieldsErrorHolder)) { $errorVar = ' errorHolder'; $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)', 'profilebuilder') . '"/>'; } $filterArray['avatarCustomField'] = ' <p class="form-upload' . $id . $errorVar . '"> <label for="' . $item_type . $id . '">' . $item_title . $errorMark . '</label> <input name="' . $item_type . $id . '" id="' . $item_type . $id . '" size="30" type="file" /><span class="wppb-max-upload">(' . __('max upload size', 'profilebuilder') . ' ' . WPPB_SERVER_MAX_UPLOAD_SIZE_MEGA . 'b)</span> <span class="wppb-description-delimiter">' . $item_desc; if ($page == 'edit_profile') { if ($userData == '' || $userData == get_bloginfo('url') . '/wp-content/uploads/profile_builder/avatars/') { $filterArray['avatarCustomField'] .= '</span><span class="wppb-description-delimiter"><u>' . __('Current avatar', 'profilebuilder') . '</u>: </span><span class="wppb-description-delimiter"><i>' . __('No uploaded avatar', 'profilebuilder') . '</i>'; } else { /* display the resized image*/ $filterArray['avatarCustomField'] .= '<br/><IMG SRC="' . $userData2 . '" TITLE="' . __('Avatar', 'profilebuilder') . '" ALT="' . __('Avatar', 'profilebuilder') . '" HEIGHT=' . $info[1] . ' WIDTH=' . $info[0] . '>'; /* display a link to the bigger image to see it clearly and a delete icon*/ if ($item_required != null && $item_required == 'yes') { $filterArray['avatarCustomField'] .= '<a href="' . $userData . '" target="_blank" class="wppb-cattachment"><img src="' . $imgSource . 'attachment.png" title="' . __('Click to see the current attachment', 'profilebuilder') . '"></a><img src="' . $imgSource . 'icon_delete_disabled.png" title="' . __('The avatar image can\'t be deleted (It was marked as required by the administrator).', 'profilebuilder') . '"></span>'; } else { $text = __('Are you sure you want to delete this avatar?', 'profilebuilder'); $filterArray['avatarCustomField'] .= '<a href="' . $userData . '" target="_blank" class="wppb-cattachment"><img src="' . $imgSource . 'attachment.png" title="' . __('Click to see the current avatar', 'profilebuilder') . '"></a><a href="javascript:confirmDelete(\'' . $wppb_nonce . '\',\'' . $currentUser . '\',\'' . $id . '\',\'' . $fieldName . '\',\'' . get_permalink() . wppb_detect_prefix() . 'fileType=avatar' . '\',\'' . get_bloginfo('url') . '/wp-admin/admin-ajax.php\',\'avatar\',\'' . $text . '\')" class="wppb-dattachment"><img src="' . $imgSource . 'icon_delete.png" title="' . __('Click to delete the avatar', 'profilebuilder') . '"></a></span>'; } } } $filterArray['avatarCustomField'] .= ' </span></p><!-- .form-upload' . $id . ' -->'; $filterArray['avatarCustomField'] = apply_filters('wppb_' . $page . '_avatar_custom_field_' . $id, $filterArray['avatarCustomField'], $userData, $userData2, $item_title, $id, $item_desc, $item_required, $errorMark, $errorVar); } return $filterArray['avatarCustomField']; }