function rc_update_user_pw() {
if (!is_user_logged_in())
return;
if (is_page('change-password')) {
$curr_user = get_current_user_id();
if (isset($_POST['submit'])) {
if (!empty($_POST['password']) && !empty($_POST['uid']))
wp_set_password( $_POST['password'], $curr_user );
}
}
}
function account_change_pw_shortcode() {
if (!is_user_logged_in())
auth_redirect();
ob_start();
$curr_user = get_current_user_id();
$login_name = new WP_User($curr_user);
rc_update_user_pw(); ?>
<div class="user_change_pw">
<form id="change_pw" method="POST">
<div class="input_wrapper uname">
<label for="loginname">Username:</label>
<input type="text" id="loginname" name="loginname" value="<?php echo $login_name->user_login ?>" disabled>
</div>
<div class="input_wrapper pw">
<label for="pass">New Password:</label>
<input type="password" id="pass" name="password"
minlength="8" required>
<span class="more_info">(8 characters minimum)</span>
</div>
<div class="input_wrapper submit">
<input type="hidden" name="uid" value="<?php echo $login_name->ID ?>">
<input type="submit" name="submit" value="Update">
</div>
</form>
<div class="process_success" style="display:none;"></div>
</div>
<?php
return ob_get_clean();
}
add_shortcode('account_change_pw', 'account_change_pw_shortcode');