From cbff642b692596213f2f319651dec95913900ae1 Mon Sep 17 00:00:00 2001 From: ultimatemember Date: Mon, 5 Jan 2015 01:33:17 +0200 Subject: [PATCH] Edits in Users Dashboard --- admin/assets/css/um-admin-columns.css | 11 ++- admin/assets/js/um-admin-users.js | 16 ---- admin/core/um-admin-actions-user.php | 5 +- admin/core/um-admin-metabox.php | 6 +- admin/core/um-admin-users.php | 77 +------------------ assets/css/um-fileupload.css | 2 +- assets/css/um-members.css | 29 +++++++ assets/css/um-modal.css | 1 + assets/css/um-profile.css | 19 +++-- assets/css/um-styles.css | 6 +- assets/dynamic_css/dynamic_profile.php | 3 +- assets/js/um-modal.js | 2 +- assets/js/um-profile.js | 6 +- assets/js/um-responsive.js | 55 +++++++++++++- assets/js/um-scripts.js | 29 +++++-- core/um-actions-core.php | 75 +++++++++++++++++++ core/um-actions-members.php | 4 +- core/um-actions-profile.php | 63 ++++++++++++++-- core/um-fields.php | 42 +++++------ core/um-files.php | 2 +- core/um-filters-fields.php | 13 ++++ core/um-filters-members.php | 100 +++++++++++++++---------- core/um-filters-user.php | 12 --- core/um-setup.php | 20 ++++- core/um-short-functions.php | 21 ++++++ core/um-user.php | 38 +++++----- 26 files changed, 429 insertions(+), 228 deletions(-) diff --git a/admin/assets/css/um-admin-columns.css b/admin/assets/css/um-admin-columns.css index 5bac6216..9aea7d70 100644 --- a/admin/assets/css/um-admin-columns.css +++ b/admin/assets/css/um-admin-columns.css @@ -17,12 +17,11 @@ .um-admin.post-type-um_role .manage-column.column-count {width: 150px} .um-admin.post-type-um_role .manage-column.column-core {width: 150px} -.um-admin.users-php .manage-column.column-username {width: 220px} -.um-admin.users-php .manage-column.column-role {width: 150px} -.um-admin.users-php .manage-column.column-name {width: 180px} -.um-admin.users-php .manage-column.column-um_role {width: 150px} -.um-admin.users-php .manage-column.column-um_status {width: 200px} -.um-admin.users-php .manage-column.column-um_info {width: 80px} +.um-admin.users-php .manage-column.column-username {width: 200px} +.um-admin.users-php .manage-column.column-role {width: 140px} +.um-admin.users-php .manage-column.column-name {width: 140px} +.um-admin.users-php .manage-column.column-um_role {width: 140px} +.um-admin.users-php .manage-column.column-um_status {width: 160px} .um-admin.users-php .tablenav.top .bulkactions, .um-admin.users-php .tablenav.bottom .bulkactions{display:none} diff --git a/admin/assets/js/um-admin-users.js b/admin/assets/js/um-admin-users.js index 28952b94..8f3f03bd 100644 --- a/admin/assets/js/um-admin-users.js +++ b/admin/assets/js/um-admin-users.js @@ -1,19 +1,3 @@ jQuery(document).ready(function() { - - jQuery('.um_single_user_action').each(function(){ - - jQuery(this).change(function(){ - - val = jQuery(this).val(); - - if ( val != '' ){ - var href= jQuery(this).parents('tr').find('a.button').attr('href'); - var new_href = href + '&um_single_user_action=' + val; - jQuery(this).parents('tr').find('a.button').attr('href',new_href); - } - - }); - - }); }); \ No newline at end of file diff --git a/admin/core/um-admin-actions-user.php b/admin/core/um-admin-actions-user.php index 442fa3f5..b3119b9c 100644 --- a/admin/core/um-admin-actions-user.php +++ b/admin/core/um-admin-actions-user.php @@ -14,6 +14,7 @@ break; case 'um_approve_membership': + case 'um_reenable': $ultimatemember->user->approve(); break; @@ -29,10 +30,6 @@ $ultimatemember->user->deactivate(); break; - case 'um_reenable': - $ultimatemember->user->approve(); - break; - case 'um_delete': $ultimatemember->user->delete(); break; diff --git a/admin/core/um-admin-metabox.php b/admin/core/um-admin-metabox.php index d24ce508..11e54ae9 100644 --- a/admin/core/um-admin-metabox.php +++ b/admin/core/um-admin-metabox.php @@ -839,9 +839,9 @@ class UM_Admin_Metabox {

diff --git a/admin/core/um-admin-users.php b/admin/core/um-admin-users.php index 3eae20e3..b6803d24 100644 --- a/admin/core/um-admin-users.php +++ b/admin/core/um-admin-users.php @@ -14,8 +14,6 @@ class UM_Admin_Users { add_action('admin_init', array(&$this, 'um_bulk_users_edit'), 9); - add_action('admin_init', array(&$this, 'um_single_user_edit'), 9); - add_filter('views_users', array(&$this, 'views_users') ); add_filter('pre_user_query', array(&$this, 'um_role_filter') ); @@ -24,29 +22,6 @@ class UM_Admin_Users { } - /*** - *** @Process an action to user via users table - ***/ - function um_single_user_edit(){ - global $ultimatemember; - - if ( !isset($_REQUEST['um_single_user']) ) return; - if ( !isset($_REQUEST['um_single_user_action']) ) return; - if ( !current_user_can('edit_users') ) wp_die( __( 'You do not have enough permissions to do that.','ultimatemember') ); - $user_id = $_REQUEST['um_single_user']; - $action = $_REQUEST['um_single_user_action']; - - $ultimatemember->user->set( $user_id ); - - do_action("um_admin_user_action_hook", $action); - - do_action("um_admin_user_action_{$action}_hook"); - - wp_redirect( add_query_arg( 'update', 'user_updated', admin_url('users.php') ) ); - exit; - - } - /*** *** @Custom row actions for users page ***/ @@ -215,9 +190,9 @@ class UM_Admin_Users {
- + @@ -257,11 +232,7 @@ class UM_Admin_Users { $columns['role'] = __('WordPress Role','ultimatemember') . $admin->_tooltip( __('This is the membership role set by WordPress','ultimatemember') ); $columns['um_status'] = __('Status','ultimatemember') . $admin->_tooltip( __('This is current user status in your membership site','ultimatemember') ); - - $columns['um_info'] = __('Details','ultimatemember') . $admin->_tooltip( __('Review the submitted registration details of this member','ultimatemember') ); - - $columns['um_actions'] = __('Actions','ultimatemember'); - + return $columns; } @@ -271,47 +242,7 @@ class UM_Admin_Users { function manage_users_custom_column($value, $column_name, $user_id) { global $ultimatemember; - - if ( 'um_info' == $column_name ) { - - um_fetch_user( $user_id ); - - if ( um_user('submitted') ) { - - return ''; - - } else { - - return '—'; - - } - - } - - if ( 'um_actions' == $column_name ) { - - um_fetch_user( $user_id ); - - $actions = $ultimatemember->user->get_admin_actions( $user_id ); - - if ( !empty( $actions ) ) { - - $edit_url = admin_url('users.php'); - $edit_url = add_query_arg('um_single_user', $user_id, $edit_url); - - $output = ''; - $output .= ''. __('Apply','ultimatemember') .''; - return $output; - - } else { - - return ''; - - } - - } - + if ( 'um_status' == $column_name ) { um_fetch_user( $user_id ); diff --git a/assets/css/um-fileupload.css b/assets/css/um-fileupload.css index deb61b5b..933265d3 100644 --- a/assets/css/um-fileupload.css +++ b/assets/css/um-fileupload.css @@ -41,7 +41,7 @@ background: #ddd; cursor: pointer; text-decoration: none !important; - z-index: 8888; + z-index: 666; opacity: 0.75; } diff --git a/assets/css/um-members.css b/assets/css/um-members.css index 33acacd3..ef008b28 100644 --- a/assets/css/um-members.css +++ b/assets/css/um-members.css @@ -107,8 +107,37 @@ border: 1px solid #eee; box-sizing: border-box; margin-bottom: 40px; + position: relative; } +.um-member.awaiting_admin_review, +.um-member.inactive, +.um-member.rejected { + opacity: 0.7; +} + +.um-member-status {display:none} +.um-member-status.awaiting_admin_review, +.um-member-status.inactive, +.um-member-status.rejected + { + display: block; + position: absolute; + top: 0; + left: 0; + width: 100%; + padding: 7px 15px; + background: #C74A4A; + color: #fff; + z-index: 10; + font-size: 13px; + box-sizing: border-box; +} + +.um-member-status.inactive, +.um-member-status.rejected +{background: #999} + .um-gutter-sizer { width: 5% } /* diff --git a/assets/css/um-modal.css b/assets/css/um-modal.css index c5628000..a6165761 100644 --- a/assets/css/um-modal.css +++ b/assets/css/um-modal.css @@ -130,6 +130,7 @@ .um-modal-btn:hover { background: #44b0ec; + color: #fff; } .um-modal-btn.alt { diff --git a/assets/css/um-profile.css b/assets/css/um-profile.css index 453ce0ba..1f48ad7e 100644 --- a/assets/css/um-profile.css +++ b/assets/css/um-profile.css @@ -129,15 +129,10 @@ top: 15px; right: 0; vertical-align: middle; - z-index: 99; font-size: 30px; height: 30px; line-height: 30px; -} - -.um-profile-edit i, .um-profile-edit i:before { - height: 30px; - vertical-align: bottom !important; + z-index: 666; } /* @@ -270,4 +265,16 @@ .um-meta-text { margin: 6px 0 0 0; color: #666; +} + +.um-profile-status {display:none} +.um-profile-status.awaiting_admin_review, +.um-profile-status.inactive, +.um-profile-status.rejected { + display: inline-block; + margin: 6px 0 0 0; + border-left: 3px solid #C74A4A; + padding-left: 10px; + font-size: 14px; + color: #777; } \ No newline at end of file diff --git a/assets/css/um-styles.css b/assets/css/um-styles.css index 8563f932..52552834 100644 --- a/assets/css/um-styles.css +++ b/assets/css/um-styles.css @@ -507,7 +507,7 @@ a.um-link-alt:hover {text-decoration: underline !important;} height: auto; background: #fff; border-radius: 5px; - z-index: 555; + z-index: 555555; display: none; border: 1px solid #e5e5e5; box-sizing: border-box; @@ -551,9 +551,13 @@ a.um-link-alt:hover {text-decoration: underline !important;} font-size: 24px; width: 24px; height: 24px; + overflow: hidden; z-index: 2; + color: #eee; } +.um-dropdown-arr * { display: block !important; width: 24px !important; height: 24px !important; vertical-align: bottom !important; overflow: hidden !important; line-height: 24px !important; } + /* - Misc. */ diff --git a/assets/dynamic_css/dynamic_profile.php b/assets/dynamic_css/dynamic_profile.php index 7e580e8d..bae20dde 100644 --- a/assets/dynamic_css/dynamic_profile.php +++ b/assets/dynamic_css/dynamic_profile.php @@ -99,7 +99,8 @@ print " if ( $header_icon_hcolor ) { print " -.um-$form_id.um .um-profile-headericon a:hover { +.um-$form_id.um .um-profile-headericon a:hover, +.um-$form_id.um .um-profile-edit-a.active { color: $header_icon_hcolor; } "; diff --git a/assets/js/um-modal.js b/assets/js/um-modal.js index 37ac714b..bb0ef1ae 100644 --- a/assets/js/um-modal.js +++ b/assets/js/um-modal.js @@ -93,7 +93,7 @@ function um_new_modal( id, size, isPhoto, source ){ jQuery('.tipsy').hide(); - jQuery('.um-dropdown').hide(); + UM_hide_menus(); jQuery('body,html,textarea').css("overflow", "hidden"); diff --git a/assets/js/um-profile.js b/assets/js/um-profile.js index c3b1a832..1c15d5db 100644 --- a/assets/js/um-profile.js +++ b/assets/js/um-profile.js @@ -3,12 +3,14 @@ jQuery(document).ready(function() { /* auto-submit form with icon */ jQuery(document).on('click', '.um-profile-save', function(e){ e.preventDefault(); - jQuery(this).parents('.um').find('form').submit(); - return false; }); + jQuery(document).on('click', '.um-profile-edit-a', function(e){ + jQuery(this).addClass('active'); + }); + /* No need to allow # */ jQuery(document).on('click', '.um-cover a, .um-photo a', function(e){ e.preventDefault(); diff --git a/assets/js/um-responsive.js b/assets/js/um-responsive.js index 9db34d8f..fa63461f 100644 --- a/assets/js/um-responsive.js +++ b/assets/js/um-responsive.js @@ -8,6 +8,53 @@ function UM_domenus(){ jQuery(element).addClass('um-trigger-menu-on-'+menu.attr('data-trigger')); + if ( jQuery(window).width() <= 1200 && element == 'div.um-profile-edit' ) { + position = 'lc'; + } + + if ( position == 'lc' ){ + + if ( 200 > jQuery(element).find('img').width() ) { + left_p = ( ( jQuery(element).width() - jQuery(element).find('img').width() ) / 2 ) + ( ( jQuery(element).find('img').width() - 200 ) / 2 ); + } else { + left_p = ( ( jQuery(element).width() - jQuery(element).find('img').width() ) / 2 ); + } + + top_ = parseInt( jQuery(element).find('a').css('top') ); + + if ( top_ ) { + top_p = jQuery(element).find('img').height() + 4 + top_; + left_gap = 4; + } else { + top_p = jQuery(element).find('img').height() + 4; + left_gap = 0; + } + + if ( top_p == 4 && element == 'div.um-cover' ) { + top_p = jQuery(element).height() / 2 + ( menu.height() / 2 ); + } else if ( top_p == 4 ) { + top_p = jQuery(element).height() + 20; + } + + gap_right = jQuery(element).width() + 17; + menu.css({ + 'top' : 0, + 'width': 200, + 'left': 'auto', + 'right' : gap_right + 'px', + 'text-align' : 'center', + }); + + menu.find('.um-dropdown-arr').find('i').removeClass().addClass('um-icon-arrow-sans-right'); + + menu.find('.um-dropdown-arr').css({ + 'top' : '4px', + 'left' : 'auto', + 'right' : '-17px', + }); + + } + if ( position == 'bc' ){ if ( 200 > jQuery(element).find('img').width() ) { @@ -28,20 +75,24 @@ function UM_domenus(){ if ( top_p == 4 && element == 'div.um-cover' ) { top_p = jQuery(element).height() / 2 + ( menu.height() / 2 ); + } else if ( top_p == 4 ) { + top_p = jQuery(element).height() + 20; } menu.css({ 'top' : top_p, 'width': 200, 'left': left_p + left_gap, + 'right' : 'auto', 'text-align' : 'center', }); - menu.find('.um-dropdown-arr').find('i').addClass('um-icon-arrow-sans-up'); + menu.find('.um-dropdown-arr').find('i').removeClass().addClass('um-icon-arrow-sans-up'); menu.find('.um-dropdown-arr').css({ - 'top' : '-18px', + 'top' : '-17px', 'left' : ( menu.width() / 2 ) - 12, + 'right' : 'auto', }); } diff --git a/assets/js/um-scripts.js b/assets/js/um-scripts.js index 10818e8d..27cdaceb 100644 --- a/assets/js/um-scripts.js +++ b/assets/js/um-scripts.js @@ -1,14 +1,24 @@ +function UM_hide_menus() { + + menu = jQuery('.um-dropdown'); + menu.parents('div').find('a').removeClass('active'); + menu.hide(); + +} + jQuery(document).ready(function() { /* dropdown menu links */ jQuery(document).on('click', '.um-dropdown a', function(e){ - e.preventDefault(); return false; }); + jQuery(document).on('click', '.um-dropdown a.real_url', function(e){ + window.location = jQuery(this).attr('href'); + }); + /* trigger dropdown on click */ jQuery(document).on('click', '.um-trigger-menu-on-click', function(e){ - e.preventDefault(); jQuery('.um-dropdown').hide(); menu = jQuery(this).find('.um-dropdown'); menu.show(); @@ -17,8 +27,7 @@ jQuery(document).ready(function() { /* hide dropdown */ jQuery(document).on('click', '.um-dropdown-hide', function(e){ - menu = jQuery(this).parents('.um-dropdown'); - menu.hide(); + UM_hide_menus(); }); /* manual triggers */ @@ -110,9 +119,15 @@ jQuery(document).ready(function() { }); /* timepicker */ - jQuery('.um-timepicker').pickatime({ - formatSubmit: 'HH:i', - hiddenSuffix: '__true' + jQuery('.um-timepicker').each(function(){ + elem = jQuery(this); + + elem.pickatime({ + format: elem.attr('data-format'), + interval: parseInt( elem.attr('data-intervals') ), + formatSubmit: 'HH:i', + hiddenName: true, + }); }); /* rating field */ diff --git a/core/um-actions-core.php b/core/um-actions-core.php index 3594fe43..ce8f3f0c 100644 --- a/core/um-actions-core.php +++ b/core/um-actions-core.php @@ -1,5 +1,80 @@ user->user_exists_by_id( $_REQUEST['uid'] ) ) return false; + + if ( isset( $_REQUEST['uid'] ) ) { + + if ( is_super_admin( $_REQUEST['uid'] ) ) + wp_die('Super administrators can not be modified.'); + + if ( !current_user_can('edit_users') ){ + wp_die('You do not have permissions to do this.'); + } + + } + + switch( $_REQUEST['um_action'] ) { + + case 'edit': + $ultimatemember->fields->editing = true; + if ( !um_can_edit_my_profile() ) { + $url = um_edit_my_profile_cancel_uri(); + exit( wp_redirect( $url ) ); + } + break; + + case 'um_reject_membership': + um_fetch_user( $_REQUEST['uid'] ); + $ultimatemember->user->reject(); + exit( wp_redirect( $ultimatemember->permalinks->get_current_url( true ) ) ); + break; + + case 'um_approve_membership': + case 'um_reenable': + um_fetch_user( $_REQUEST['uid'] ); + $ultimatemember->user->approve(); + exit( wp_redirect( $ultimatemember->permalinks->get_current_url( true ) ) ); + break; + + case 'um_put_as_pending': + um_fetch_user( $_REQUEST['uid'] ); + $ultimatemember->user->pending(); + exit( wp_redirect( $ultimatemember->permalinks->get_current_url( true ) ) ); + break; + + case 'um_resend_activation': + um_fetch_user( $_REQUEST['uid'] ); + $ultimatemember->user->email_pending(); + exit( wp_redirect( $ultimatemember->permalinks->get_current_url( true ) ) ); + break; + + case 'um_deactivate': + um_fetch_user( $_REQUEST['uid'] ); + $ultimatemember->user->deactivate(); + exit( wp_redirect( $ultimatemember->permalinks->get_current_url( true ) ) ); + break; + + case 'um_delete': + um_fetch_user( $_REQUEST['uid'] ); + $ultimatemember->user->delete(); + exit( wp_redirect( $ultimatemember->permalinks->get_current_url( true ) ) ); + break; + + } + + } + /*** *** @prevent moving core posts to trash ***/ diff --git a/core/um-actions-members.php b/core/um-actions-members.php index 35d943a1..d81b01ac 100644 --- a/core/um-actions-members.php +++ b/core/um-actions-members.php @@ -201,8 +201,10 @@ -
+
+ +
diff --git a/core/um-actions-profile.php b/core/um-actions-profile.php index 92a5e9f3..e93de8cc 100644 --- a/core/um-actions-profile.php +++ b/core/um-actions-profile.php @@ -85,7 +85,11 @@ mobile->isMobile() ){ - echo um_user('cover_photo', 300); + if ( $ultimatemember->mobile->isTablet() ) { + echo um_user('cover_photo', 1000); + } else { + echo um_user('cover_photo', 300); + } } else { echo um_user('cover_photo', 1000); } @@ -144,7 +148,7 @@ user->cannot_edit ) ) { $ultimatemember->fields->add_hidden_field( 'profile_photo' ); @@ -200,6 +204,10 @@ +
+ +
+
@@ -254,12 +262,53 @@ if ( isset( $ultimatemember->user->cannot_edit ) && $ultimatemember->user->cannot_edit == 1 ) return; if ( $ultimatemember->fields->editing == true ) { - $output .= '
'; - } else { - $output .= '
'; + + ?> + +
+ + + +
+ + + +
+ + + + menu->new_ui( 'bc', 'div.um-profile-edit', 'click', array( + ''.__('My Account','ultimatemember').'', + ''.__('Edit Profile','ultimatemember').'', + ''.__('Cancel','ultimatemember').'', + ), 'can_edit_user' ); + + } else { + + $actions = $ultimatemember->user->get_admin_actions(); + + $menu_items = array( + ''.__('Edit Profile','ultimatemember').'', + ''.__('Cancel','ultimatemember').'', + ); + + $menu_items = array_merge( $actions, $menu_items ); + + echo $ultimatemember->menu->new_ui( 'bc', 'div.um-profile-edit', 'click', $menu_items, 'can_edit_user' ); + + } + + ?> + +
+ + editing = false; $this->viewing = false; - - add_action('init', array(&$this, 'init_edit_my_profile'), 10); - + } /*** @@ -53,24 +51,6 @@ class UM_Fields { } - /*** - *** @detect if we're editing profile in shortcode - ***/ - function init_edit_my_profile() { - - global $ultimatemember; - - if ( !is_admin() && isset( $_REQUEST['um_action'] ) && $_REQUEST['um_action'] == 'edit' ) { - $this->editing = true; - - if ( !um_can_edit_my_profile() ) { - $url = um_edit_my_profile_cancel_uri(); - exit( wp_redirect( $url ) ); - } - } - - } - /*** *** @update a field globally ***/ @@ -623,6 +603,24 @@ class UM_Fields { $array['input'] = 'text'; + if ( !isset( $array['format'] ) ) $array['format'] = 'g:i a'; + + switch( $array['format'] ) { + case 'g:i a': + $js_format = 'h:i a'; + break; + case 'g:i A': + $js_format = 'h:i A'; + break; + case 'H:i': + $js_format = 'HH:i'; + break; + } + + $array['js_format'] = $js_format; + + if ( !isset( $array['intervals'] ) ) $array['intervals'] = 60; + if (!isset($array['autocomplete'])) $array['autocomplete'] = 'on'; break; @@ -1021,7 +1019,7 @@ class UM_Fields { } - $output .= ' + $output .= '
'; diff --git a/core/um-files.php b/core/um-files.php index 39f2ec56..e6988bb6 100644 --- a/core/um-files.php +++ b/core/um-files.php @@ -300,7 +300,7 @@ class UM_Files { $data = $ultimatemember->fields->get_field($field); if ( $fileinfo['invalid_image'] == true ) { - $error = $data['invalid_image']; + $error = sprintf(__('Your image is invalid or too large!','ultimatemember') ); } elseif ( !$this->in_array( $fileinfo['extension'], $data['allowed_types'] ) ) { $error = $data['extension_error']; } elseif ( isset($data['min_size']) && ( $fileinfo['size'] < $data['min_size'] ) ) { diff --git a/core/um-filters-fields.php b/core/um-filters-fields.php index 82c3ebab..cb04a224 100644 --- a/core/um-filters-fields.php +++ b/core/um-filters-fields.php @@ -9,6 +9,19 @@ return $label; } + /*** + *** @Time + ***/ + add_filter('um_profile_field_filter_hook__time', 'um_profile_field_filter_hook__time', 99, 2); + function um_profile_field_filter_hook__time( $value, $data ) { + global $ultimatemember; + $value = $ultimatemember->datetime->format( $value, $data['format'] ); + + $value = str_replace('am', 'a.m.', $value ); + $value = str_replace('pm', 'p.m.', $value ); + return $value; + } + /*** *** @Dates ***/ diff --git a/core/um-filters-members.php b/core/um-filters-members.php index 4aadfa9e..1c5b5c30 100644 --- a/core/um-filters-members.php +++ b/core/um-filters-members.php @@ -1,10 +1,70 @@ 'account_status', + 'value' => 'approved', + 'compare' => '=' + ); + + return $query_args; + } + + /*** + *** @adds search parameters + ***/ + function um_add_search_to_query( $query_args, $args ){ + global $ultimatemember; + extract( $args ); + + if ( isset( $_REQUEST['um_search'] ) ) { + + $query = $ultimatemember->permalinks->get_query_array(); + + foreach( $query as $field => $value ) { + + if ( $value && $field != 'um_search' ) { + + $query_args['meta_query'][] = array( + 'key' => $field, + 'value' => $value, + 'compare' => '=' + ); + + } + + } + + } + + if ( count ($query_args['meta_query']) == 1 ) { + unset( $query_args['meta_query'] ); + } + + return $query_args; + + } + + /*** + *** @adds main parameters + ***/ function um_prepare_user_query_args($query_args, $args){ + global $ultimatemember; extract( $args ); $query_args['fields'] = 'ID'; @@ -68,7 +128,7 @@ } /*** - *** @print out result array + *** @hook in the member results array ***/ add_filter('um_prepare_user_results_array', 'um_prepare_user_results_array', 50, 2); function um_prepare_user_results_array($result){ @@ -80,40 +140,4 @@ } return $result; - } - - /*** - *** @adding search filters - ***/ - add_filter('um_prepare_user_query_args', 'um_add_search_to_query', 50, 2); - function um_add_search_to_query($query_args, $args){ - global $ultimatemember; - extract( $args ); - - if ( isset( $_REQUEST['um_search'] ) ) { - - $query = $ultimatemember->permalinks->get_query_array(); - - foreach( $query as $field => $value ) { - - if ( $value && $field != 'um_search' ) { - - $query_args['meta_query'][] = array( - 'key' => $field, - 'value' => $value, - 'compare' => '=' - ); - - } - - } - - } - - if ( count ($query_args['meta_query']) == 1 ) { - unset( $query_args['meta_query'] ); - } - - return $query_args; - } \ No newline at end of file diff --git a/core/um-filters-user.php b/core/um-filters-user.php index da6c87c4..b2419790 100644 --- a/core/um-filters-user.php +++ b/core/um-filters-user.php @@ -32,38 +32,26 @@ if ( um_user('account_status') == 'awaiting_admin_review' ){ $actions['um_approve_membership'] = array( 'label' => __('Approve Membership') ); $actions['um_reject_membership'] = array( 'label' => __('Reject Membership') ); - } else { - $actions['um_approve_membership'] = array( 'label' => __('Approve Membership'), 'disabled' => 'disabled' ); - $actions['um_reject_membership'] = array( 'label' => __('Reject Membership'), 'disabled' => 'disabled' ); } if ( um_user('account_status') == 'rejected' ) { $actions['um_approve_membership'] = array( 'label' => __('Approve Membership') ); - $actions['um_reject_membership'] = array( 'label' => __('Reject Membership'), 'disabled' => 'disabled' ); } if ( um_user('account_status') == 'approved' ) { $actions['um_put_as_pending'] = array( 'label' => __('Put as Pending Review') ); - } else { - $actions['um_put_as_pending'] = array( 'label' => __('Put as Pending Review'), 'disabled' => 'disabled' ); } if ( um_user('account_status') == 'awaiting_email_confirmation' ) { $actions['um_resend_activation'] = array( 'label' => __('Resend Activation E-mail') ); - } else { - $actions['um_resend_activation'] = array( 'label' => __('Resend Activation E-mail'), 'disabled' => 'disabled' ); } if ( um_user('account_status') != 'inactive' ) { $actions['um_deactivate'] = array( 'label' => __('Deactivate this account') ); - } else { - $actions['um_deactivate'] = array( 'label' => __('Deactivate this account'), 'disabled' => 'disabled' ); } if ( um_user('account_status') == 'inactive' ) { $actions['um_reenable'] = array( 'label' => __('Reactivate this account') ); - } else { - $actions['um_reenable'] = array( 'label' => __('Reactivate this account'), 'disabled' => 'disabled' ); } $actions['um_delete'] = array( 'label' => __('Delete this user') ); diff --git a/core/um-setup.php b/core/um-setup.php index 8a2f7456..091407d5 100644 --- a/core/um-setup.php +++ b/core/um-setup.php @@ -370,11 +370,23 @@ class UM_Setup { $users = get_users( array('fields' => 'ID') ); foreach( $users as $id ) { - if ( !is_super_admin( $id ) ) { - update_user_meta( $id, 'role', 'member' ); - } else { - update_user_meta( $id, 'role', 'admin' ); + + if ( !get_user_meta( $id, 'account_status', true ) ) { + + update_user_meta( $id, 'account_status', 'approved' ); + } + + if ( !is_super_admin( $id ) ) { + + update_user_meta( $id, 'role', 'member' ); + + } else { + + update_user_meta( $id, 'role', 'admin' ); + + } + } } diff --git a/core/um-short-functions.php b/core/um-short-functions.php index 0e592c61..484b333d 100644 --- a/core/um-short-functions.php +++ b/core/um-short-functions.php @@ -334,6 +334,10 @@ function um_can_view_profile( $user_id ){ global $ultimatemember; + if ( !current_user_can('manage_options') && !$ultimatemember->user->is_approved( $user_id ) ) { + return false; + } + if ( !is_user_logged_in() ) { if ( $ultimatemember->user->is_private_profile( $user_id ) ) { return false; @@ -404,9 +408,13 @@ global $ultimatemember; if ( !is_user_logged_in() ) return false; + if ( um_user('can_edit_everyone') ) return true; + if ( get_current_user_id() == $user_id && um_user('can_edit_profile') ) return true; + if ( get_current_user_id() == $user_id && !um_user('can_edit_profile') ) return false; + if ( !um_user('can_edit_everyone') ) return false; return true; @@ -426,6 +434,19 @@ } + /*** + *** @quick test if the user's is on his profile + ***/ + function um_is_myprofile(){ + global $ultimatemember; + + if ( get_current_user_id() && get_current_user_id() == um_get_requested_user() )return true; + + if ( !um_get_requested_user() && um_is_core_page('user') && get_current_user_id() ) return true; + + return false; + } + /*** *** @short for admin e-mail ***/ diff --git a/core/um-user.php b/core/um-user.php index 1640f0bf..71d9df46 100644 --- a/core/um-user.php +++ b/core/um-user.php @@ -356,46 +356,33 @@ class UM_User { function get_bulk_admin_actions() { $output = ''; $actions = array(); - $actions = apply_filters('um_admin_bulk_user_actions_hook', $actions ); - foreach($actions as $id => $arr ) { - if ( isset($arr['disabled'])){ $arr['disabled'] = 'disabled'; } else { $arr['disabled'] = ''; } - + $output .= ''; - } return $output; } /*** - *** @Get admin actions as dropdown list + *** @Get admin actions for individual user ***/ function get_admin_actions() { - $output = ''; + $items = ''; $actions = array(); - $actions = apply_filters('um_admin_user_actions_hook', $actions ); - if ( !isset( $actions ) || empty( $actions ) ) return false; - foreach($actions as $id => $arr ) { - - if ( isset($arr['disabled'])){ - $arr['disabled'] = 'disabled'; - } else { - $arr['disabled'] = ''; - } - - $output .= ''; - + $url = add_query_arg('um_action', $id ); + $url = add_query_arg('uid', um_profile_id(), $url ); + $items[] = '' . $arr['label'] . ''; } - return $output; + return $items; } /*** @@ -409,6 +396,17 @@ class UM_User { return false; } + /*** + *** @If it is un-approved profile + ***/ + function is_approved( $user_id ) { + $status = get_user_meta( $user_id, 'account_status', true ); + if ( $status == 'approved' || $status == '' ) { + return true; + } + return false; + } + /*** *** @update files ***/