diff --git a/assets/css/um-account.css b/assets/css/um-account.css index 6ed1a2ea..4942e817 100644 --- a/assets/css/um-account.css +++ b/assets/css/um-account.css @@ -73,7 +73,7 @@ .um-account-name a { font-weight: bold; - color: #333; + color: #555; text-decoration: none !important; font-size: 18px; } @@ -168,7 +168,7 @@ float: left; height: 30px; line-height: 30px; - color: #444; + color: #555; } .um-account-side li a:hover {color: #444; background: #ddd} diff --git a/core/um-actions-profile.php b/core/um-actions-profile.php index 1fce98b6..4b2f153e 100644 --- a/core/um-actions-profile.php +++ b/core/um-actions-profile.php @@ -1,5 +1,75 @@ user->set( $args['user_id'] ); + } else { + wp_die( __('You are not allowed to edit this user.','ultimatemember') ); + } + } else if ( isset( $args['_user_id'] ) ) { + $ultimatemember->user->set( $args['_user_id'] ); + } + + $userinfo = $ultimatemember->user->profile; + + $fields = unserialize( $args['custom_fields'] ); + + do_action('um_user_before_updating_profile', $userinfo ); + + // loop through fields + foreach( $fields as $key => $array ) { + + if ( $fields[$key]['type'] == 'multiselect' || $fields[$key]['type'] == 'checkbox' && !isset($args['submitted'][$key]) ) { + delete_user_meta( um_user('ID'), $key ); + } + + if ( isset( $args['submitted'][ $key ] ) ) { + + if ( isset( $userinfo[$key]) && $args['submitted'][$key] != $userinfo[$key] ) { + $to_update[ $key ] = $args['submitted'][ $key ]; + } else if ( $args['submitted'][$key] ) { + $to_update[ $key ] = $args['submitted'][ $key ]; + } + + // files + if ( isset( $fields[$key]['type'] ) && in_array( $fields[$key]['type'], array('image','file') ) && um_is_temp_upload( $args['submitted'][ $key ] ) ) { + $files[ $key ] = $args['submitted'][ $key ]; + } + + } + } + + if ( isset( $args['submitted']['description'] ) ) { + $to_update['description'] = $ultimatemember->validation->remove_html( $args['submitted']['description'] ); + } + + if ( is_array( $to_update ) ) { + $ultimatemember->user->update_profile( $to_update ); + } + + if ( is_array( $files ) ) { + $ultimatemember->user->update_files( $files ); + } + + do_action('um_user_after_updating_profile', $to_update ); + + if ( !isset( $args['is_signup'] ) ) { + exit( wp_redirect( um_edit_my_profile_cancel_uri() ) ); + } + + } + /*** *** @if editing another user ***/ @@ -295,6 +365,7 @@ $items = array( 'editprofile' => ''.__('Edit Profile','ultimatemember').'', 'myaccount' => ''.__('My Account','ultimatemember').'', + 'logout' => ''.__('Logout','ultimatemember').'', 'cancel' => ''.__('Cancel','ultimatemember').'', ); @@ -305,6 +376,7 @@ $actions = $ultimatemember->user->get_admin_actions(); unset( $items['myaccount'] ); + unset( $items['logout'] ); unset( $items['cancel'] ); $items = array_merge( $items, $actions ); $items['cancel'] = $cancel; @@ -328,72 +400,6 @@ } - /*** - *** @update user's profile - ***/ - add_action('um_user_edit_profile', 'um_user_edit_profile', 10); - function um_user_edit_profile($args){ - - global $ultimatemember; - - $to_update = null; - $files = null; - - if ( isset( $args['user_id'] ) ) { - if ( um_current_user_can('edit', $args['user_id'] ) ) { - $ultimatemember->user->set( $args['user_id'] ); - } else { - wp_die( __('You are not allowed to edit this user.','ultimatemember') ); - } - } - - $userinfo = $ultimatemember->user->profile; - - $fields = unserialize( $args['custom_fields'] ); - - do_action('um_user_before_updating_profile', $userinfo ); - - // loop through fields - foreach( $fields as $key => $array ) { - - if ( $fields[$key]['type'] == 'multiselect' || $fields[$key]['type'] == 'checkbox' && !isset($args['submitted'][$key]) ) { - delete_user_meta( um_user('ID'), $key ); - } - - if ( isset( $args['submitted'][ $key ] ) ) { - - if ( isset( $userinfo[$key]) && $args['submitted'][$key] != $userinfo[$key] ) { - $to_update[ $key ] = $args['submitted'][ $key ]; - } else if ( $args['submitted'][$key] ) { - $to_update[ $key ] = $args['submitted'][ $key ]; - } - - // files - if ( isset( $fields[$key]['type'] ) && in_array( $fields[$key]['type'], array('image','file') ) && um_is_temp_upload( $args['submitted'][ $key ] ) ) { - $files[ $key ] = $args['submitted'][ $key ]; - } - - } - } - - if ( isset( $args['submitted']['description'] ) ) { - $to_update['description'] = $ultimatemember->validation->remove_html( $args['submitted']['description'] ); - } - - if ( is_array( $to_update ) ) { - $ultimatemember->user->update_profile( $to_update ); - } - - if ( is_array( $files ) ) { - $ultimatemember->user->update_files( $files ); - } - - do_action('um_user_after_updating_profile', $to_update ); - - exit( wp_redirect( um_edit_my_profile_cancel_uri() ) ); - - } - /*** *** @Show Fields ***/ diff --git a/core/um-actions-register.php b/core/um-actions-register.php index 16aa150b..524d478d 100644 --- a/core/um-actions-register.php +++ b/core/um-actions-register.php @@ -54,7 +54,7 @@ $unique_userID = $ultimatemember->query->count_users() + 1; if( !isset($user_email) ) { - $user_email = 'nobody' . $unique_userID . '@' . bloginfo('name'); + $user_email = 'nobody' . $unique_userID . '@' . get_bloginfo('name'); } if ( !isset( $user_login ) ) { @@ -91,12 +91,29 @@ $ultimatemember->user->set_registration_details( $args['submitted'] ); + do_action('um_post_registration_save', $user_id, $args); + do_action('um_post_registration_listener', $user_id, $args); do_action('um_post_registration', $user_id, $args); } + /*** + *** @Update user's profile after registration + ***/ + add_action('um_post_registration_save', 'um_post_registration_save', 10, 2); + function um_post_registration_save($user_id, $args){ + global $ultimatemember; + + unset( $args['user_id'] ); + $args['_user_id'] = $user_id; + $args['is_signup'] = 1; + + do_action('um_user_edit_profile', $args); + + } + /*** *** @post-registration admin listender ***/ diff --git a/core/um-setup.php b/core/um-setup.php index 618e642d..595c140b 100644 --- a/core/um-setup.php +++ b/core/um-setup.php @@ -170,9 +170,7 @@ class UM_Setup { 'core' => 'admin', 'can_access_wpadmin' => 1, 'can_edit_everyone' => 1, - 'can_edit_roles' => 1, 'can_delete_everyone' => 1, - 'can_delete_roles' => 1, 'can_edit_profile' => 1, 'can_delete_profile' => 1, 'can_view_all' => 1, @@ -190,9 +188,7 @@ class UM_Setup { 'core' => 'member', 'can_access_wpadmin' => 0, 'can_edit_everyone' => 0, - 'can_edit_roles' => 0, 'can_delete_everyone' => 0, - 'can_delete_roles' => 0, 'can_make_private_profile' => 0, 'can_access_private_profile' => 0, 'after_login' => 'redirect_profile', diff --git a/core/um-user.php b/core/um-user.php index 3d5f15a3..b503401f 100644 --- a/core/um-user.php +++ b/core/um-user.php @@ -198,12 +198,6 @@ class UM_User { ***/ function set_status( $status ){ - $old_status = ( isset( $this->profile['account_status'] ) ) ? $this->profile['account_status'] : 'null'; - - if ( $status == $old_status ) return; // to prevent spam - - do_action('um_before_user_status_is_changed', $old_status ); - $this->profile['account_status'] = $status; $this->update_usermeta_info('account_status'); @@ -423,11 +417,11 @@ class UM_User { /*** *** @update files ***/ - function update_files( $array ) { + function update_files( $changes ) { global $ultimatemember; - foreach( $array as $key => $uri ) { + foreach( $changes as $key => $uri ) { $src = um_is_temp_upload( $uri ); $ultimatemember->files->new_user_upload( $this->id, $src, $key ); }