A client gave a WP page to fix some problems. Specifically, there was a front end profile page that was not updating information as it was meant to. After I started testing, it all updates, but if you update your password it leaves you logged in.
What I want to happen is to log the user out, send them to the login page with a “enter new password” message. Can anyone point me in the right direction?
Here is the submit:
<p class="form-submit">
<input name="updateuser" type="submit" id="updateuser" class="submit button" value=" <?php _e('Update Profile', 'profile'); ?>" />
<?php wp_nonce_field( 'update-user' ) ?>
<input name="action" type="hidden" id="action" value="update-user" />
<input type="hidden" name="updated" value="is-update" />
</p>
And here is the password update:
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'] ) ) );
$success[] = __('Password successfuly updated.', 'profile');
//wp_logout();
// $logInLink = wp_login_url( get_bloginfo('url') );
// wp_logout_url($logInLink);
// wp_login_form();
}
else {
$error[] = __('The passwords you entered do not match. Your password was not updated.', 'profile');
}
}
The commented stuff is what I have tried without success.
in your script, after you update the data
use wp_logout() and wp_redirect() or wp_safe_redirect()