mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
Many changes in core to be more WordPress native
This commit is contained in:
@@ -17,9 +17,6 @@
|
||||
.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 .tablenav.top .bulkactions,
|
||||
.um-admin.users-php .tablenav.bottom .bulkactions{display:none}
|
||||
|
||||
.um-admin.post-type-um_form td.column-shortcode,
|
||||
.um-admin.post-type-um_form td.column-id,
|
||||
.um-admin.post-type-um_directory td.column-shortcode,
|
||||
|
||||
@@ -1,18 +1,3 @@
|
||||
body.um-admin .actions,
|
||||
body.um-admin .bulkactions {
|
||||
float: left;
|
||||
margin: 0!important;
|
||||
padding:0!important;
|
||||
top: 0!important;
|
||||
}
|
||||
|
||||
body.um-admin .actions .button {
|
||||
height: 29px !important;
|
||||
margin: 0 12px 0 0 !important;
|
||||
display: inline !important;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
body.um-admin .select2-container {margin-right: 2px!important;}
|
||||
|
||||
body.um-admin .select2-drop,
|
||||
|
||||
@@ -81,12 +81,6 @@ jQuery(document).ready(function() {
|
||||
minimumResultsForSearch: 10
|
||||
});
|
||||
|
||||
jQuery("body.um-admin .actions select:not('.umaf-selectjs')").select2({
|
||||
allowClear: false,
|
||||
minimumResultsForSearch: 10,
|
||||
width: '160px'
|
||||
});
|
||||
|
||||
/**
|
||||
Tooltips
|
||||
**/
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
break;
|
||||
|
||||
case 'um_delete':
|
||||
if ( is_admin() )
|
||||
wp_die('This action is not allowed in backend.','ultimatemember');
|
||||
$ultimatemember->user->delete();
|
||||
break;
|
||||
|
||||
|
||||
@@ -186,68 +186,6 @@
|
||||
}
|
||||
}
|
||||
add_action('save_post', 'um_admin_delete_role_cache', 1111, 2);
|
||||
|
||||
/***
|
||||
*** @delete users need confirmation
|
||||
***/
|
||||
add_action('um_admin_do_action__delete_users', 'um_admin_do_action__delete_users');
|
||||
function um_admin_do_action__delete_users( $action ){
|
||||
global $ultimatemember;
|
||||
if ( !is_admin() || !current_user_can( 'edit_users' ) ) die();
|
||||
|
||||
$redirect = admin_url('users.php');
|
||||
|
||||
$users = array_map( 'intval', (array) $_REQUEST['user'] );
|
||||
if ( !$users ) exit( wp_redirect( $redirect ) );
|
||||
|
||||
if ( isset( $_REQUEST['confirm'] ) && $_REQUEST['confirm'] == 1 ) { // delete
|
||||
|
||||
$bulk_action = 'um_delete';
|
||||
|
||||
foreach($users as $user_id){
|
||||
$ultimatemember->user->set( $user_id );
|
||||
if ( !um_user('super_admin') ) {
|
||||
|
||||
do_action("um_admin_user_action_hook", $bulk_action);
|
||||
|
||||
do_action("um_admin_user_action_{$bulk_action}_hook");
|
||||
|
||||
} else {
|
||||
$admin_err = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Finished. redirect now
|
||||
if ( $admin_err == 0 ){
|
||||
wp_redirect( admin_url('users.php?update=users_updated') );
|
||||
exit;
|
||||
} else {
|
||||
wp_redirect( admin_url('users.php?update=err_users_updated') );
|
||||
exit;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$redirect = add_query_arg('update','confirm_delete',$redirect);
|
||||
|
||||
foreach( $users as $id ) {
|
||||
$query .= '&user[]='.$id;
|
||||
}
|
||||
|
||||
$uri = $ultimatemember->permalinks->get_current_url( true );
|
||||
$uri = add_query_arg('um_adm_action', 'delete_users', $uri);
|
||||
foreach( $users as $user_id ) {
|
||||
$uri = add_query_arg('user[]', $user_id, $uri);
|
||||
$redirect = add_query_arg('user[]', $user_id, $redirect);
|
||||
}
|
||||
$uri = add_query_arg('_refer', $_POST['_wp_http_referer'], $redirect);
|
||||
$redirect = add_query_arg('confirm', 1, $uri);
|
||||
|
||||
exit( wp_redirect($redirect) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
*** @clear user cache
|
||||
|
||||
@@ -7,21 +7,21 @@ class UM_Admin_Users {
|
||||
$this->custom_role = 'um_role';
|
||||
|
||||
add_filter('manage_users_columns', array(&$this, 'manage_users_columns') );
|
||||
|
||||
|
||||
add_action('manage_users_custom_column', array(&$this, 'manage_users_custom_column'), 10, 3);
|
||||
|
||||
|
||||
add_action('restrict_manage_users', array(&$this, 'restrict_manage_users') );
|
||||
|
||||
|
||||
add_action('admin_init', array(&$this, 'um_bulk_users_edit'), 9);
|
||||
|
||||
|
||||
add_filter('views_users', array(&$this, 'views_users') );
|
||||
|
||||
|
||||
add_filter('pre_user_query', array(&$this, 'sort_by_newest') );
|
||||
|
||||
|
||||
add_filter('pre_user_query', array(&$this, 'custom_users_filter') );
|
||||
|
||||
|
||||
add_filter('user_row_actions', array(&$this, 'user_row_actions'), 10, 2);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/***
|
||||
@@ -32,17 +32,14 @@ class UM_Admin_Users {
|
||||
$user_id = $user_object->ID;
|
||||
um_fetch_user( $user_id );
|
||||
|
||||
unset( $actions['edit'] );
|
||||
unset( $actions['delete'] );
|
||||
$actions['frontend_profile'] = "<a class='' href='" . um_user_profile_url() . "'>" . __( 'View profile','ultimatemember') . "</a>";
|
||||
|
||||
$actions['frontend_profile'] = "<a class='' href='" . um_user_profile_url() . "'>" . __( 'Profile','ultimatemember') . "</a>";
|
||||
|
||||
if ( um_user('submitted') ) {
|
||||
$actions['view_info'] = '<a href="#" data-modal="UM_preview_registration" data-modal-size="smaller" data-dynamic-content="um_admin_review_registration" data-arg1="'.$user_id.'" data-arg2="edit_registration">' . __('Info','ultimatemember') . '</a>';
|
||||
}
|
||||
|
||||
|
||||
$actions = apply_filters('um_admin_user_row_actions', $actions, $user_id );
|
||||
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
@@ -208,22 +205,7 @@ class UM_Admin_Users {
|
||||
|
||||
$users = $_REQUEST['users'];
|
||||
$bulk_action = current( array_filter( $_REQUEST['um_bulk_action']) );
|
||||
|
||||
if ( 'um_delete' == $bulk_action ) { // this needs confirmation
|
||||
|
||||
$uri = admin_url('users.php');
|
||||
$userids = array_map( 'intval', (array) $_REQUEST['users'] );
|
||||
|
||||
if ( is_array( $userids ) ) {
|
||||
$uri = add_query_arg('um_adm_action', 'delete_users', $uri);
|
||||
foreach( $userids as $user_id ) {
|
||||
$uri = add_query_arg('user[]', $user_id, $uri);
|
||||
}
|
||||
exit( wp_redirect( $uri ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach($users as $user_id){
|
||||
$ultimatemember->user->set( $user_id );
|
||||
if ( !um_user('super_admin') ) {
|
||||
@@ -273,10 +255,10 @@ class UM_Admin_Users {
|
||||
global $ultimatemember;
|
||||
?>
|
||||
|
||||
<div class="actions">
|
||||
<div style="float:right;margin:0 4px">
|
||||
|
||||
<label class="screen-reader-text" for="um_filter_role"><?php _e('Filter by','ultimatemember'); ?></label>
|
||||
<select name="um_filter_role[]" id="um_filter_role" class="umaf-selectjs" style="width: 120px">
|
||||
<select name="um_filter_role[]" id="um_filter_role" class="" style="width: 120px">
|
||||
<option value="0"><?php _e('Filter by','ultimatemember'); ?></option>
|
||||
<?php
|
||||
$roles = $ultimatemember->query->get_roles();
|
||||
@@ -290,11 +272,11 @@ class UM_Admin_Users {
|
||||
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<div style="float:right;margin:0 4px">
|
||||
|
||||
<label class="screen-reader-text" for="um_bulk_action"><?php _e('Take Action','ultimatemember'); ?></label>
|
||||
<select name="um_bulk_action[]" id="um_bulk_action" class="umaf-selectjs" style="width: 200px">
|
||||
<option value="0"><?php _e('Take Action','ultimatemember'); ?></option>
|
||||
<label class="screen-reader-text" for="um_bulk_action"><?php _e('UM Action','ultimatemember'); ?></label>
|
||||
<select name="um_bulk_action[]" id="um_bulk_action" class="" style="width: 200px">
|
||||
<option value="0"><?php _e('UM Action','ultimatemember'); ?></option>
|
||||
<?php echo $ultimatemember->user->get_bulk_admin_actions(); ?>
|
||||
</select>
|
||||
|
||||
@@ -302,10 +284,10 @@ class UM_Admin_Users {
|
||||
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<div style="float:right;margin:0 4px">
|
||||
|
||||
<label class="screen-reader-text" for="um_change_role"><?php _e('Community role…','ultimatemember'); ?></label>
|
||||
<select name="um_change_role[]" id="um_change_role" class="umaf-selectjs" style="width: 160px">
|
||||
<select name="um_change_role[]" id="um_change_role" class="" style="width: 160px">
|
||||
<?php foreach($ultimatemember->query->get_roles( $add_default = 'Community role…' ) as $key => $value) { ?>
|
||||
<option value="<?php echo $key; ?>"><?php echo $value; ?></option>
|
||||
<?php } ?>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
$actions['um_resend_activation'] = array( 'label' => __('Resend Activation E-mail','ultimatemember') );
|
||||
$actions['um_deactivate'] = array( 'label' => __('Deactivate','ultimatemember') );
|
||||
$actions['um_reenable'] = array( 'label' => __('Reactivate','ultimatemember') );
|
||||
$actions['um_delete'] = array( 'label' => __('Delete','ultimatemember') );
|
||||
//$actions['um_delete'] = array( 'label' => __('Delete','ultimatemember') );
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,49 @@ class UM_User {
|
||||
add_action('um_when_role_is_set', array(&$this, 'remove_cache') );
|
||||
add_action('um_when_status_is_set', array(&$this, 'remove_cache') );
|
||||
|
||||
add_action( 'show_user_profile', array( $this, 'community_role_edit' ) );
|
||||
add_action( 'edit_user_profile', array( $this, 'community_role_edit' ) );
|
||||
add_action( 'personal_options_update', array( $this, 'community_role_save' ) );
|
||||
add_action( 'edit_user_profile_update', array( $this, 'community_role_save' ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow changing community role
|
||||
*/
|
||||
function community_role_edit( $user ) {
|
||||
global $ultimatemember;
|
||||
if ( current_user_can( 'edit_users' ) && current_user_can( 'edit_user', $user->ID ) ) {
|
||||
$user = get_userdata( $user->ID );
|
||||
?>
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>
|
||||
<label for="um_role"><?php _e( 'Community Role', 'ultimatemember' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<select name="um_role" id="um_role">
|
||||
<?php foreach( $ultimatemember->query->get_roles() as $key => $value ) { ?>
|
||||
<option value="<?php echo $key; ?>" <?php selected( um_user('role'), $key ); ?> ><?php echo $value; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<span class="description"><?php _e( 'Assign or change the community role for this user', 'ultimatemember' ); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php }
|
||||
}
|
||||
|
||||
/**
|
||||
* Save community role
|
||||
*/
|
||||
public function community_role_save( $user_id ) {
|
||||
if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['um_role'] ) ) {
|
||||
update_user_meta( $user_id, 'role', sanitize_title_with_dashes( $_POST['um_role'] ) );
|
||||
delete_option( "um_cache_userdata_{$user_id}" );
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
|
||||
Reference in New Issue
Block a user