</div> </td> </tr> <tr> <th><?php _e('Confirm Password', 'makery'); ?> </th> <td> <div class="field-wrap"> <input type="password" name="confirm_password" value="" /> </div> </td> </tr> <?php if (ThemexFacebook::isUpdated(ThemexUser::$data['current']['ID'])) { ?> <tr> <th><?php _e('Current Password', 'makery'); ?> </th> <td> <div class="field-wrap"> <input type="password" name="current_password" value="" /> </div> </td> </tr> <?php } ?>
/** * Updates user settings * * @access public * @param int $ID * @param array $data * @return void */ public static function updateSettings($ID, $data) { $current = get_user_by('id', $ID); $facebook = ThemexFacebook::isUpdated($ID); $required = false; $user = array('ID' => $ID); //password $new_password = trim(themex_value('new_password', $data)); if (!empty($new_password)) { $confirm_password = trim(themex_value('confirm_password', $data)); $user['user_pass'] = $new_password; $required = true; if (strlen($new_password) < 4) { ThemexInterface::$messages[] = __('Password must be at least 4 characters long', 'makery'); } else { if (strlen($new_password) > 16) { ThemexInterface::$messages[] = __('Password must be not more than 16 characters long', 'makery'); } else { if (preg_match("/^([a-zA-Z0-9@#-_\$%^&+=!?]{1,20})\$/", $new_password) == 0) { ThemexInterface::$messages[] = __('Password contains invalid characters', 'makery'); } else { if ($new_password != $confirm_password) { ThemexInterface::$messages[] = __('Passwords do not match', 'makery'); } } } } } //email $email = trim(themex_value('email', $data)); if ($email != $current->user_email) { $user['user_email'] = $email; $required = true; if (!is_email($email)) { ThemexInterface::$messages[] = __('Email address is invalid', 'makery'); } } //notices $notices = themex_value('notices', $data); ThemexCore::updateUserMeta($ID, 'notices', $notices); $current_password = trim(themex_value('current_password', $data)); if ($required && $facebook && !wp_check_password($current_password, $current->user_pass, $current->ID)) { ThemexInterface::$messages[] = __('Current password is incorrect', 'makery'); } if (empty(ThemexInterface::$messages)) { wp_update_user($user); if (isset($user['user_pass']) && !$facebook) { ThemexFacebook::updateUser($ID); } ThemexInterface::$messages[] = __('Settings have been successfully saved', 'makery'); $_POST['success'] = true; } }