From 756eb1d7bed9087816676e015beacc790344e711 Mon Sep 17 00:00:00 2001 From: jonfalcon Date: Sun, 24 Jan 2016 15:13:13 -0800 Subject: [PATCH] Fix account deletion on one submission --- core/um-actions-account.php | 238 ++++++++++++++++++------------------ 1 file changed, 119 insertions(+), 119 deletions(-) diff --git a/core/um-actions-account.php b/core/um-actions-account.php index fabe8831..ec7a97d2 100644 --- a/core/um-actions-account.php +++ b/core/um-actions-account.php @@ -7,10 +7,12 @@ function um_submit_account_details( $args ) { global $ultimatemember; + $tab = ( get_query_var('um_tab') ) ? get_query_var('um_tab') : 'general'; + if ( $_POST['user_password'] && $_POST['confirm_user_password'] ) { $changes['user_pass'] = $_POST['user_password']; add_filter('send_password_change_email','um_send_password_change_email'); - + } foreach( $_POST as $k => $v ) { @@ -18,7 +20,7 @@ $changes[ $k ] = $v; } } - + if ( isset( $changes['hide_in_members'] ) && $changes['hide_in_members'] == __('No','ultimatemember') ) { delete_user_meta( um_user('ID'), 'hide_in_members' ); unset( $changes['hide_in_members'] ); @@ -26,11 +28,11 @@ // fired on account page, just before updating profile do_action('um_account_pre_update_profile', $changes, um_user('ID') ); - + $ultimatemember->user->update_profile( $changes ); // delete account - if ( $_POST['single_user_password'] && isset($_POST['um_account_submit']) && $_POST['um_account_submit'] == __('Delete Account','ultimatemember') ) { + if ( $_POST['single_user_password'] && $tab == 'delete' ) { if ( current_user_can('delete_users') || um_user('can_delete_profile') ) { if ( !um_user('super_admin') ) { $ultimatemember->user->delete(); @@ -44,17 +46,15 @@ } } } - + do_action('um_post_account_update'); - + do_action('um_after_user_account_updated', get_current_user_id() ); - - $tab = ( get_query_var('um_tab') ) ? get_query_var('um_tab') : 'general'; - + $url = $ultimatemember->account->tab_link( $tab ); - + $url = add_query_arg( 'updated', 'account', $url ); - + if ( function_exists('icl_get_current_language') ) { if ( icl_get_current_language() != icl_get_default_language() ) { $url = $ultimatemember->permalinks->get_current_url( true ); @@ -62,76 +62,76 @@ exit( wp_redirect( $url ) ); } } - + exit( wp_redirect( $url ) ); - + } - + /*** *** @validate for errors in account page ***/ add_action('um_submit_account_errors_hook','um_submit_account_errors_hook'); function um_submit_account_errors_hook( $args ) { global $ultimatemember; - + // errors on general tab if ( isset($_POST['um_account_submit']) && $_POST['um_account_submit'] != __('Delete Account','ultimatemember') ) { - + if ( isset($_POST['first_name']) && strlen(trim( $_POST['first_name'] ) ) == 0 ) { $ultimatemember->form->add_error('first_name', __('You must provide your first name','ultimatemember') ); } - + if ( isset($_POST['last_name']) && strlen(trim( $_POST['last_name'] ) ) == 0 ) { $ultimatemember->form->add_error('last_name', __('You must provide your last name','ultimatemember') ); } - + if ( isset($_POST['user_email']) && strlen(trim( $_POST['user_email'] ) ) == 0 ) { $ultimatemember->form->add_error('user_email', __('You must provide your e-mail','ultimatemember') ); } - + if ( isset($_POST['user_email']) && !is_email( $_POST['user_email'] ) ) { $ultimatemember->form->add_error('user_email', __('Please provide a valid e-mail','ultimatemember') ); } - + if ( email_exists( $_POST['user_email'] ) && email_exists( $_POST['user_email'] ) != get_current_user_id() ) { $ultimatemember->form->add_error('user_email', __('Email already linked to another account','ultimatemember') ); } - + } $ultimatemember->account->current_tab = 'general'; - + // change password if ( $_POST['current_user_password'] != '' ) { if ( !wp_check_password( $_POST['current_user_password'], um_user('user_pass'), um_user('ID') ) ) { $ultimatemember->form->add_error('current_user_password', __('This is not your password','ultimatemember') ); $ultimatemember->account->current_tab = 'password'; } else { // correct password - + if ( $_POST['user_password'] != $_POST['confirm_user_password'] && $_POST['user_password'] ) { $ultimatemember->form->add_error('user_password', __('Your new password does not match','ultimatemember') ); $ultimatemember->account->current_tab = 'password'; } - + if ( um_get_option('account_require_strongpass') ) { - + if ( strlen( utf8_decode( $_POST['user_password'] ) ) < 8 ) { $ultimatemember->form->add_error('user_password', __('Your password must contain at least 8 characters','ultimatemember') ); - } - + } + if ( strlen( utf8_decode( $_POST['user_password'] ) ) > 30 ) { $ultimatemember->form->add_error('user_password', __('Your password must contain less than 30 characters','ultimatemember') ); } - + if ( !$ultimatemember->validation->strong_pass( $_POST['user_password'] ) ) { $ultimatemember->form->add_error('user_password', __('Your password must contain at least one lowercase letter, one capital letter and one number','ultimatemember') ); $ultimatemember->account->current_tab = 'password'; } - + } - + } } - + // delete account if ( isset($_POST['um_account_submit']) && $_POST['um_account_submit'] == __('Delete Account','ultimatemember') ) { if ( strlen(trim( $_POST['single_user_password'] ) ) == 0 ) { @@ -143,23 +143,23 @@ } $ultimatemember->account->current_tab = 'delete'; } - + } - + /*** *** @hidden inputs for account page ***/ add_action('um_account_page_hidden_fields','um_account_page_hidden_fields'); function um_account_page_hidden_fields( $args ) { - + ?> - + - + account->get_tab_output('delete'); - + if ( $output ) { ?> - +
- + - + - + - +
- + account->get_tab_output('privacy'); if ( $output ) { ?> - +
- + - + - +
- + account->get_tab_output('general'); - + if ( $output ) { ?> - +
- + - + - +
- + account->get_tab_output('password'); - + if ( $output ) { ?> - +
- + - + - +
- + account->get_tab_output('notifications'); - + if ( $output ) { ?> - +
- +
- + - + - +
- + - +
- + - + - +
- + - +
- + - + mobile->isMobile() ) { ?> - + - + - + - + - + - +
- + account->tabs = apply_filters('um_account_page_default_tabs_hook', $tabs=array() ); - + ksort( $ultimatemember->account->tabs ); - + ?> - +