153 lines
6.4 KiB
PHP
153 lines
6.4 KiB
PHP
<?php
|
|
/*
|
|
Template Name: Edit Profile
|
|
*/
|
|
|
|
/* Get user info. */
|
|
global $current_user, $wp_roles; get_currentuserinfo();
|
|
|
|
/* Load the registration file. */
|
|
require_once(ABSPATH . WPINC . '/registration.php');
|
|
require_once(ABSPATH . 'wp-admin/includes' . '/template.php'); // this is only for the selected() function
|
|
|
|
/* If profile was saved, update profile. */
|
|
if ('POST' == $_SERVER['REQUEST_METHOD'] && !empty($_POST['action']) && $_POST['action'] == 'update-user') {
|
|
|
|
/* Update user password. */
|
|
if (!empty($_POST['pass1']) && !empty($_POST['pass2'])) {
|
|
if ($_POST['pass1'] == $_POST['pass2'])
|
|
wp_update_user(array('ID' => $current_user->id, 'user_pass' => esc_attr($_POST['pass1'])));
|
|
else
|
|
$error = __('The passwords you entered do not match. Your password was not updated.', 'gp_lang');
|
|
}
|
|
|
|
/* Update user information. */
|
|
|
|
update_user_meta($current_user->id, 'first_name', esc_attr($_POST['first_name']));
|
|
|
|
update_user_meta($current_user->id, 'last_name', esc_attr($_POST['last_name']));
|
|
|
|
if (!empty($_POST['nickname']))
|
|
update_user_meta($current_user->id, 'nickname', esc_attr($_POST['nickname']));
|
|
|
|
update_user_meta($current_user->id, 'user_identity', esc_attr($_POST['user_identity']));
|
|
|
|
if (!empty($_POST['email']))
|
|
update_user_meta($current_user->id, 'user_email', esc_attr($_POST['email']));
|
|
|
|
if(strpos($_POST['website'], 'ttp://') || empty($_POST['website']))
|
|
update_user_meta($current_user->id, 'user_url', esc_attr($_POST['website']));
|
|
else
|
|
update_user_meta($current_user->id, 'user_url', 'http://' . esc_attr($_POST['website']));
|
|
|
|
update_user_meta($current_user->id, 'aim', esc_attr($_POST['aim']));
|
|
|
|
update_user_meta($current_user->id, 'yim', esc_attr($_POST['yim']));
|
|
|
|
update_user_meta($current_user->id, 'jabber', esc_attr($_POST['jabber']));
|
|
|
|
update_user_meta($current_user->id, 'description', esc_attr($_POST['description']));
|
|
|
|
/* Redirect so the page will show updated info. */
|
|
/*if (!$error) {
|
|
wp_redirect(get_peramlink());
|
|
exit;
|
|
}*/
|
|
}
|
|
|
|
|
|
?>
|
|
|
|
|
|
<?php if(!is_user_logged_in()) { ?>
|
|
|
|
<strong><?php _e('You must login to your account in order to edit your profile.', 'gp_lang'); ?></strong>
|
|
|
|
<?php } else { ?>
|
|
|
|
<?php if($error) echo '<p class="error">' . $error . '</p>'; ?>
|
|
|
|
<form method="post" id="edituser" class="user-forms lightbox-form" action="<?php echo home_url(); ?>/?author=<?php echo $current_user->ID; ?>">
|
|
|
|
<h3><?php _e('Edit Profile', 'gp_lang'); ?></h3>
|
|
|
|
<p class="first_name">
|
|
<input class="text-input" name="first_name" type="text" id="first_name" value="<?php the_author_meta('first_name', $current_user->id); ?>" /> <label for="first_name"><?php _e('First Name', 'gp_lang'); ?></label>
|
|
</p>
|
|
|
|
<p class="last_name">
|
|
<input class="text-input" name="last_name" type="text" id="last_name" value="<?php the_author_meta('last_name', $current_user->id); ?>" /> <label for="last_name"><?php _e('Last Name', 'gp_lang'); ?></label>
|
|
</p>
|
|
|
|
<p class="nickname">
|
|
<input class="text-input" name="nickname" type="text" id="nickname" value="<?php the_author_meta('nickname', $current_user->id); ?>" /> <label for="nickname"><?php _e('Nickname', 'gp_lang'); ?></label>
|
|
</p>
|
|
|
|
<p class="user_identity">
|
|
<select name="user_identity" id="user_identity">
|
|
<?php
|
|
$public_display = array();
|
|
$public_display['display_nickname'] = $current_user->nickname;
|
|
$public_display['display_username'] = $current_user->user_login;
|
|
if (!empty($current_user->first_name))
|
|
$public_display['display_firstname'] = $current_user->first_name;
|
|
if (!empty($current_user->last_name))
|
|
$public_display['display_lastname'] = $current_user->last_name;
|
|
if (!empty($current_user->first_name) && !empty($current_user->last_name)) {
|
|
$public_display['display_firstlast'] = $current_user->first_name . ' ' . $current_user->last_name;
|
|
$public_display['display_lastfirst'] = $current_user->last_name . ' ' . $current_user->first_name;
|
|
}
|
|
if (!in_array($current_user->user_identity, $public_display))// Only add this if it isn't duplicated elsewhere
|
|
$public_display = array('display_displayname' => $current_user->user_identity) + $public_display;
|
|
$public_display = array_map('trim', $public_display);
|
|
foreach ($public_display as $id => $item) {
|
|
?>
|
|
<option id="<?php echo $id; ?>" value="<?php echo esc_attr($item); ?>"<?php selected($current_user->user_identity, $item); ?>><?php echo $item; ?></option>
|
|
<?php
|
|
}
|
|
?>
|
|
</select> <label for="user_identity"><?php _e('Display Name', 'gp_lang'); ?></label>
|
|
</p>
|
|
|
|
<p class="form-email">
|
|
<input class="text-input" name="email" type="text" id="email" value="<?php the_author_meta('user_email', $current_user->id); ?>" /> <label for="email"><?php _e('Email', 'gp_lang'); ?></label>
|
|
</p>
|
|
|
|
<p class="form-website">
|
|
<input class="text-input" name="website" type="text" id="website" value="<?php the_author_meta('user_url', $current_user->id); ?>" /> <label for="website"><?php _e('Website', 'gp_lang'); ?></label>
|
|
</p>
|
|
|
|
<p class="form-aim">
|
|
<input class="text-input" name="aim" type="text" id="aim" value="<?php the_author_meta('aim', $current_user->id); ?>" /> <label for="aim"><?php _e('AIM', 'gp_lang'); ?></label>
|
|
</p>
|
|
|
|
<p class="form-yim">
|
|
<input class="text-input" name="yim" type="text" id="yim" value="<?php the_author_meta('yim', $current_user->id); ?>" /> <label for="yim"><?php _e('Yahoo', 'gp_lang'); ?></label>
|
|
</p>
|
|
|
|
<p class="form-jabber">
|
|
<input class="text-input" name="jabber" type="text" id="jabber" value="<?php the_author_meta('jabber', $current_user->id); ?>" /> <label for="jabber"><?php _e('Jabber / Google Talk', 'gp_lang'); ?></label>
|
|
</p>
|
|
|
|
<p class="form-description">
|
|
<textarea class="text-input" name="description" id="description" rows="5" cols="30"><?php echo the_author_meta('description', $current_user->id); ?></textarea> <label for="description"><?php _e('Bio', 'gp_lang'); ?></label>
|
|
</p>
|
|
|
|
<p class="form-password">
|
|
<input class="text-input" name="pass1" type="password" id="pass1" /> <label for="pass1"><?php _e('New Password', 'gp_lang'); ?></label>
|
|
</p>
|
|
|
|
<p class="form-password">
|
|
<input class="text-input" name="pass2" type="password" id="pass2" /> <label for="pass2"><?php _e('Repeat Password', 'gp_lang'); ?></label>
|
|
</p>
|
|
|
|
<p class="form-submit">
|
|
<?php echo $referer; ?>
|
|
<input name="updateuser" type="submit" id="updateuser" value="<?php _e('Update →', 'gp_lang'); ?>" />
|
|
<?php wp_nonce_field('update-user') ?>
|
|
<input name="action" type="hidden" id="action" value="update-user" />
|
|
</p>
|
|
|
|
</form>
|
|
|
|
<?php } ?>
|