mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-18 22:23:37 +09:00
Merge branch 'development/2.8.x' into feature/action-schedule-integration
This commit is contained in:
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
namespace um\admin;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'um\admin\Actions_Listener' ) ) {
|
||||
|
||||
/**
|
||||
* Class Actions_Listener
|
||||
*
|
||||
* @package um\admin
|
||||
*/
|
||||
class Actions_Listener {
|
||||
|
||||
/**
|
||||
* Actions_Listener constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'admin_init', array( $this, 'actions_listener' ) );
|
||||
add_filter( 'um_adm_action_individual_nonce_actions', array( $this, 'extends_individual_nonce_actions' ) ); // @todo remove soon after UM core update
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle wp-admin actions
|
||||
*
|
||||
* @since 2.8.7
|
||||
*/
|
||||
public function actions_listener() {
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! empty( $_REQUEST['um_adm_action'] ) ) {
|
||||
switch ( sanitize_key( $_REQUEST['um_adm_action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification -- there is nonce verification below for each case
|
||||
case 'approve_user':
|
||||
if ( empty( $_REQUEST['uid'] ) || ! is_numeric( $_REQUEST['uid'] ) ) {
|
||||
die( esc_html__( 'Invalid user ID', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
$user_id = absint( $_REQUEST['uid'] );
|
||||
|
||||
check_admin_referer( "approve_user{$user_id}" );
|
||||
|
||||
$redirect = wp_get_referer();
|
||||
if ( UM()->common()->users()->can_current_user_edit_user( $user_id ) ) {
|
||||
$result = UM()->common()->users()->approve( $user_id );
|
||||
if ( $result ) {
|
||||
$redirect = add_query_arg(
|
||||
array(
|
||||
'update' => 'um_approved',
|
||||
'approved_count' => 1,
|
||||
),
|
||||
$redirect
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
wp_safe_redirect( $redirect );
|
||||
exit;
|
||||
case 'reactivate_user':
|
||||
if ( empty( $_REQUEST['uid'] ) || ! is_numeric( $_REQUEST['uid'] ) ) {
|
||||
die( esc_html__( 'Invalid user ID', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
$user_id = absint( $_REQUEST['uid'] );
|
||||
|
||||
check_admin_referer( "reactivate_user{$user_id}" );
|
||||
|
||||
$redirect = wp_get_referer();
|
||||
if ( UM()->common()->users()->can_current_user_edit_user( $user_id ) ) {
|
||||
$result = UM()->common()->users()->reactivate( $user_id );
|
||||
if ( $result ) {
|
||||
$redirect = add_query_arg(
|
||||
array(
|
||||
'update' => 'um_reactivated',
|
||||
'reactivated_count' => 1,
|
||||
),
|
||||
$redirect
|
||||
);
|
||||
}
|
||||
}
|
||||
wp_safe_redirect( $redirect );
|
||||
exit;
|
||||
case 'put_user_as_pending':
|
||||
if ( empty( $_REQUEST['uid'] ) || ! is_numeric( $_REQUEST['uid'] ) ) {
|
||||
die( esc_html__( 'Invalid user ID', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
$user_id = absint( $_REQUEST['uid'] );
|
||||
|
||||
check_admin_referer( "put_user_as_pending{$user_id}" );
|
||||
|
||||
$redirect = wp_get_referer();
|
||||
if ( UM()->common()->users()->can_current_user_edit_user( $user_id ) ) {
|
||||
$result = UM()->common()->users()->set_as_pending( $user_id );
|
||||
if ( $result ) {
|
||||
$redirect = add_query_arg(
|
||||
array(
|
||||
'update' => 'um_pending',
|
||||
'pending_count' => 1,
|
||||
),
|
||||
$redirect
|
||||
);
|
||||
}
|
||||
}
|
||||
wp_safe_redirect( $redirect );
|
||||
exit;
|
||||
case 'resend_user_activation':
|
||||
if ( empty( $_REQUEST['uid'] ) || ! is_numeric( $_REQUEST['uid'] ) ) {
|
||||
die( esc_html__( 'Invalid user ID', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
$user_id = absint( $_REQUEST['uid'] );
|
||||
|
||||
check_admin_referer( "resend_user_activation{$user_id}" );
|
||||
|
||||
$redirect = wp_get_referer();
|
||||
if ( UM()->common()->users()->can_current_user_edit_user( $user_id ) ) {
|
||||
$result = UM()->common()->users()->send_activation( $user_id, true );
|
||||
if ( $result ) {
|
||||
$redirect = add_query_arg(
|
||||
array(
|
||||
'update' => 'um_resend_activation',
|
||||
'resend_activation_count' => 1,
|
||||
),
|
||||
$redirect
|
||||
);
|
||||
}
|
||||
}
|
||||
wp_safe_redirect( $redirect );
|
||||
exit;
|
||||
case 'reject_user':
|
||||
if ( empty( $_REQUEST['uid'] ) || ! is_numeric( $_REQUEST['uid'] ) ) {
|
||||
die( esc_html__( 'Invalid user ID', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
$user_id = absint( $_REQUEST['uid'] );
|
||||
|
||||
check_admin_referer( "reject_user{$user_id}" );
|
||||
|
||||
$redirect = wp_get_referer();
|
||||
if ( UM()->common()->users()->can_current_user_edit_user( $user_id ) ) {
|
||||
$result = UM()->common()->users()->reject( $user_id );
|
||||
if ( $result ) {
|
||||
$redirect = add_query_arg(
|
||||
array(
|
||||
'update' => 'um_rejected',
|
||||
'rejected_count' => 1,
|
||||
),
|
||||
$redirect
|
||||
);
|
||||
}
|
||||
}
|
||||
wp_safe_redirect( $redirect );
|
||||
exit;
|
||||
case 'deactivate_user':
|
||||
if ( empty( $_REQUEST['uid'] ) || ! is_numeric( $_REQUEST['uid'] ) ) {
|
||||
die( esc_html__( 'Invalid user ID', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
$user_id = absint( $_REQUEST['uid'] );
|
||||
|
||||
check_admin_referer( "deactivate_user{$user_id}" );
|
||||
|
||||
$redirect = wp_get_referer();
|
||||
if ( UM()->common()->users()->can_current_user_edit_user( $user_id ) ) {
|
||||
$result = UM()->common()->users()->deactivate( $user_id );
|
||||
if ( $result ) {
|
||||
$redirect = add_query_arg(
|
||||
array(
|
||||
'update' => 'um_deactivate',
|
||||
'deactivated_count' => 1,
|
||||
),
|
||||
$redirect
|
||||
);
|
||||
}
|
||||
}
|
||||
wp_safe_redirect( $redirect );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function extends_individual_nonce_actions( $actions ) {
|
||||
$actions[] = 'approve_user';
|
||||
$actions[] = 'reactivate_user';
|
||||
$actions[] = 'put_user_as_pending';
|
||||
$actions[] = 'resend_user_activation';
|
||||
$actions[] = 'reject_user';
|
||||
$actions[] = 'deactivate_user';
|
||||
return $actions;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,6 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
|
||||
add_action( 'um_admin_do_action__purge_temp', array( &$this, 'purge_temp' ) );
|
||||
add_action( 'um_admin_do_action__manual_upgrades_request', array( &$this, 'manual_upgrades_request' ) );
|
||||
add_action( 'um_admin_do_action__duplicate_form', array( &$this, 'duplicate_form' ) );
|
||||
add_action( 'um_admin_do_action__user_action', array( &$this, 'user_action' ) );
|
||||
add_action( 'um_admin_do_action__check_templates_version', array( &$this, 'check_templates_version' ) );
|
||||
|
||||
add_action( 'um_admin_do_action__install_core_pages', array( &$this, 'install_core_pages' ) );
|
||||
@@ -79,10 +78,12 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
|
||||
}
|
||||
|
||||
public function includes() {
|
||||
$this->actions_listener();
|
||||
$this->enqueue();
|
||||
$this->notices();
|
||||
$this->secure();
|
||||
$this->site_health();
|
||||
$this->users_columns();
|
||||
}
|
||||
|
||||
public function init_variables() {
|
||||
@@ -1531,6 +1532,13 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
|
||||
$sanitized[ $k ] = absint( $v );
|
||||
}
|
||||
break;
|
||||
case 'empty_absint':
|
||||
if ( is_array( $v ) ) {
|
||||
$sanitized[ $k ] = array_map( 'absint', $v );
|
||||
} else {
|
||||
$sanitized[ $k ] = ( '' !== $v ) ? absint( $v ) : '';
|
||||
}
|
||||
break;
|
||||
case 'key':
|
||||
if ( is_array( $v ) ) {
|
||||
$sanitized[ $k ] = array_map( 'sanitize_key', $v );
|
||||
@@ -1759,6 +1767,8 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
|
||||
delete_transient( "um_count_users_{$status}" );
|
||||
}
|
||||
|
||||
delete_transient( 'um_count_users_all' );
|
||||
|
||||
do_action( 'um_flush_user_status_cache' );
|
||||
|
||||
$url = add_query_arg(
|
||||
@@ -1840,69 +1850,6 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Various user actions.
|
||||
*/
|
||||
public function user_action() {
|
||||
if ( ! current_user_can( 'edit_users' ) ) {
|
||||
die();
|
||||
}
|
||||
if ( ! isset( $_REQUEST['sub'] ) ) {
|
||||
die();
|
||||
}
|
||||
if ( ! isset( $_REQUEST['user_id'] ) ) {
|
||||
die();
|
||||
}
|
||||
|
||||
um_fetch_user( absint( $_REQUEST['user_id'] ) );
|
||||
|
||||
$subaction = sanitize_key( $_REQUEST['sub'] );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_admin_user_action_hook
|
||||
* @description Action on bulk user subaction
|
||||
* @input_vars
|
||||
* [{"var":"$subaction","type":"string","desc":"Bulk Subaction"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_admin_user_action_hook', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_admin_user_action_hook', 'my_admin_user_action', 10, 1 );
|
||||
* function my_admin_user_action( $subaction ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_admin_user_action_hook', $subaction );
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_admin_user_action_{$subaction}_hook
|
||||
* @description Action on bulk user subaction
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_admin_user_action_{$subaction}_hook', 'function_name', 10 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_admin_user_action_{$subaction}_hook', 'my_admin_user_action', 10 );
|
||||
* function my_admin_user_action() {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( "um_admin_user_action_{$subaction}_hook" );
|
||||
|
||||
um_reset_user();
|
||||
|
||||
wp_safe_redirect( add_query_arg( 'update', 'um_user_updated', admin_url( '?page=ultimatemember' ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Manual check templates versions.
|
||||
*/
|
||||
@@ -1946,7 +1893,6 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
|
||||
$action = sanitize_key( $_REQUEST['um_adm_action'] );
|
||||
|
||||
$individual_nonce_actions = array(
|
||||
'user_action',
|
||||
'duplicate_form',
|
||||
);
|
||||
$individual_nonce_actions = apply_filters( 'um_adm_action_individual_nonce_actions', $individual_nonce_actions );
|
||||
@@ -2071,6 +2017,18 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
|
||||
return $parent_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.8.7
|
||||
*
|
||||
* @return Actions_Listener
|
||||
*/
|
||||
public function actions_listener() {
|
||||
if ( empty( UM()->classes['um\admin\actions_listener'] ) ) {
|
||||
UM()->classes['um\admin\actions_listener'] = new Actions_Listener();
|
||||
}
|
||||
return UM()->classes['um\admin\actions_listener'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.7.0
|
||||
*
|
||||
@@ -2130,5 +2088,17 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
|
||||
}
|
||||
return UM()->classes['um\admin\site_health'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.8.7
|
||||
*
|
||||
* @return Users_Columns
|
||||
*/
|
||||
public function users_columns() {
|
||||
if ( empty( UM()->classes['um\admin\users_columns'] ) ) {
|
||||
UM()->classes['um\admin\users_columns'] = new Users_Columns();
|
||||
}
|
||||
return UM()->classes['um\admin\users_columns'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,8 @@ if ( ! class_exists( 'um\admin\Secure' ) ) {
|
||||
}
|
||||
// Restore Account Status.
|
||||
if ( isset( $metadata['account_status'] ) ) {
|
||||
UM()->user()->set_status( $metadata['account_status'] );
|
||||
// Force update of the user status without email notifications.
|
||||
UM()->common()->users()->set_status( $user_id, $metadata['account_status'] );
|
||||
}
|
||||
|
||||
// Delete blocked meta.
|
||||
@@ -327,7 +328,7 @@ if ( ! class_exists( 'um\admin\Secure' ) ) {
|
||||
if ( 'account_status' === $column_name ) {
|
||||
um_fetch_user( $user_id );
|
||||
$is_blocked = um_user( 'um_user_blocked' );
|
||||
$account_status = um_user( 'account_status' );
|
||||
$account_status = UM()->common()->users()->get_status( $user_id );
|
||||
if ( ! empty( $is_blocked ) && in_array( $account_status, array( 'rejected', 'inactive' ), true ) ) {
|
||||
$datetime = um_user( 'um_user_blocked__timestamp' );
|
||||
$val .= '<div><small>' . esc_html__( 'Blocked Due to Suspicious Activity', 'ultimate-member' ) . '</small></div>';
|
||||
|
||||
@@ -0,0 +1,644 @@
|
||||
<?php
|
||||
namespace um\admin;
|
||||
|
||||
use WP_User;
|
||||
use WP_User_Query;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'um\admin\Users_Columns' ) ) {
|
||||
|
||||
/**
|
||||
* Class Users_Columns
|
||||
*
|
||||
* @package um\admin
|
||||
*/
|
||||
class Users_Columns {
|
||||
|
||||
/**
|
||||
* Users_Columns constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_filter( 'manage_users_columns', array( &$this, 'manage_users_columns' ) );
|
||||
add_filter( 'manage_users_custom_column', array( &$this, 'manage_users_custom_column' ), 10, 3 );
|
||||
|
||||
add_action( 'pre_user_query', array( &$this, 'sort_by_newest' ) );
|
||||
add_filter( 'users_list_table_query_args', array( &$this, 'hide_by_caps' ), 1 );
|
||||
add_filter( 'views_users', array( &$this, 'restrict_role_links' ) );
|
||||
|
||||
add_filter( 'user_row_actions', array( &$this, 'user_row_actions' ), 10, 2 );
|
||||
add_filter( 'bulk_actions-users', array( &$this, 'add_bulk_actions' ) );
|
||||
add_filter( 'handle_bulk_actions-users', array( &$this, 'handle_bulk_actions' ), 10, 3 );
|
||||
|
||||
add_action( 'manage_users_extra_tablenav', array( &$this, 'add_status_filter' ) );
|
||||
add_action( 'pre_user_query', array( &$this, 'filter_users_by_status' ) );
|
||||
|
||||
add_filter( 'removable_query_args', array( &$this, 'add_removable_query_args' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter: Add column 'Status'
|
||||
*
|
||||
* @param array $columns
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function manage_users_columns( $columns ) {
|
||||
$columns['um_account_status'] = __( 'Status', 'ultimate-member' );
|
||||
return $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter: Show column 'Status'
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $column_name
|
||||
* @param int $user_id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function manage_users_custom_column( $value, $column_name, $user_id ) {
|
||||
if ( 'um_account_status' !== $column_name ) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$status = UM()->common()->users()->get_status( $user_id, 'formatted' );
|
||||
|
||||
$status = apply_filters( 'um_users_column_account_status', $status, $user_id );
|
||||
|
||||
$value = '<span class="um-user-status">' . esc_html( $status ) . '</span>';
|
||||
|
||||
if ( get_current_user_id() === $user_id ) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$row_actions = array();
|
||||
if ( UM()->common()->users()->can_be_approved( $user_id ) ) {
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'um_adm_action' => 'approve_user',
|
||||
'uid' => $user_id,
|
||||
'_wpnonce' => wp_create_nonce( 'approve_user' . $user_id ),
|
||||
),
|
||||
admin_url( 'users.php' )
|
||||
);
|
||||
|
||||
$row_actions[] = '<a href="' . esc_url( $url ) . '" class="um-set-status-approved">' . esc_html__( 'Approve', 'ultimate-member' ) . '</a>';
|
||||
}
|
||||
if ( UM()->common()->users()->can_be_rejected( $user_id ) ) {
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'um_adm_action' => 'reject_user',
|
||||
'uid' => $user_id,
|
||||
'_wpnonce' => wp_create_nonce( 'reject_user' . $user_id ),
|
||||
),
|
||||
admin_url( 'users.php' )
|
||||
);
|
||||
|
||||
$row_actions[] = '<a href="' . esc_url( $url ) . '" class="um-set-status-rejected" onclick="return confirm( \'' . esc_js( __( 'Are you sure you want to reject this user membership?', 'ultimate-member' ) ) . '\' );">' . esc_html__( 'Reject', 'ultimate-member' ) . '</a>';
|
||||
}
|
||||
if ( UM()->common()->users()->can_be_reactivated( $user_id ) ) {
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'um_adm_action' => 'reactivate_user',
|
||||
'uid' => $user_id,
|
||||
'_wpnonce' => wp_create_nonce( 'reactivate_user' . $user_id ),
|
||||
),
|
||||
admin_url( 'users.php' )
|
||||
);
|
||||
|
||||
$row_actions[] = '<a href="' . esc_url( $url ) . '" class="um-reactivate-user">' . esc_html__( 'Reactivate', 'ultimate-member' ) . '</a>';
|
||||
}
|
||||
if ( UM()->common()->users()->can_be_set_as_pending( $user_id ) ) {
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'um_adm_action' => 'put_user_as_pending',
|
||||
'uid' => $user_id,
|
||||
'_wpnonce' => wp_create_nonce( 'put_user_as_pending' . $user_id ),
|
||||
),
|
||||
admin_url( 'users.php' )
|
||||
);
|
||||
|
||||
$row_actions[] = '<a href="' . esc_url( $url ) . '" class="um-set-status-pending">' . esc_html__( 'Put as pending', 'ultimate-member' ) . '</a>';
|
||||
}
|
||||
if ( UM()->common()->users()->can_activation_send( $user_id ) ) {
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'um_adm_action' => 'resend_user_activation',
|
||||
'uid' => $user_id,
|
||||
'_wpnonce' => wp_create_nonce( 'resend_user_activation' . $user_id ),
|
||||
),
|
||||
admin_url( 'users.php' )
|
||||
);
|
||||
|
||||
$title = __( 'Send activation email', 'ultimate-member' );
|
||||
if ( UM()->common()->users()->has_status( $user_id, 'awaiting_email_confirmation' ) ) {
|
||||
$title = __( 'Resend activation email', 'ultimate-member' );
|
||||
}
|
||||
|
||||
$row_actions[] = '<a href="' . esc_url( $url ) . '" class="um-resend-activation-email">' . esc_html( $title ) . '</a>';
|
||||
}
|
||||
if ( UM()->common()->users()->can_be_deactivated( $user_id ) ) {
|
||||
$url = add_query_arg(
|
||||
array(
|
||||
'um_adm_action' => 'deactivate_user',
|
||||
'uid' => $user_id,
|
||||
'_wpnonce' => wp_create_nonce( 'deactivate_user' . $user_id ),
|
||||
),
|
||||
admin_url( 'users.php' )
|
||||
);
|
||||
|
||||
$row_actions[] = '<a href="' . esc_url( $url ) . '" class="um-deactivate-user" onclick="return confirm( \'' . esc_js( __( 'Are you sure you want to deactivate this user?', 'ultimate-member' ) ) . '\' );">' . esc_html__( 'Deactivate', 'ultimate-member' ) . '</a>';
|
||||
}
|
||||
|
||||
$row_actions = apply_filters( 'um_users_column_account_status_row_actions', $row_actions, $user_id );
|
||||
if ( ! empty( $row_actions ) ) {
|
||||
$value .= '<div class="row-actions"><ul class="um-user-status-row-actions"><li>' . implode( '</li><li> | </li><li>', $row_actions ) . '</li></ul></div>';
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change default sorting at WP Users list table
|
||||
*
|
||||
* @param WP_User_Query $query Current instance of WP_User_Query (passed by reference).
|
||||
*/
|
||||
public function sort_by_newest( $query ) {
|
||||
global $pagenow;
|
||||
|
||||
// phpcs:ignore WordPress.Security.NonceVerification -- situated in WP native query and just checking sorting
|
||||
if ( 'users.php' === $pagenow && ! isset( $_REQUEST['orderby'] ) && is_admin() ) {
|
||||
$query->query_vars['order'] = 'desc';
|
||||
$query->query_orderby = ' ORDER BY user_registered DESC';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide users who are hidden by role access for not Administrator user
|
||||
*
|
||||
* @param array $args Arguments passed to WP_User_Query to retrieve items for the current
|
||||
* users list table
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function hide_by_caps( $args ) {
|
||||
if ( current_user_can( 'manage_options' ) ) {
|
||||
return $args;
|
||||
}
|
||||
|
||||
// @todo avoid um_user() function using
|
||||
// @todo check another restrictions not only the role settings. We need to exclude users per user ID.
|
||||
$can_view_roles = um_user( 'can_view_roles' );
|
||||
if ( ! empty( $can_view_roles ) && um_user( 'can_view_all' ) ) {
|
||||
$args['role__in'] = $can_view_roles;
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide role filters with not accessible roles
|
||||
*
|
||||
* @param array $views
|
||||
* @return array
|
||||
*/
|
||||
public function restrict_role_links( $views ) {
|
||||
if ( current_user_can( 'manage_options' ) ) {
|
||||
return $views;
|
||||
}
|
||||
|
||||
$can_view_roles = um_user( 'can_view_roles' );
|
||||
if ( ! empty( $can_view_roles ) && um_user( 'can_view_all' ) ) {
|
||||
$wp_roles = wp_roles();
|
||||
foreach ( $wp_roles->get_names() as $this_role => $name ) {
|
||||
if ( ! in_array( $this_role, $can_view_roles, true ) ) {
|
||||
unset( $views[ $this_role ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $views;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom row actions for users page
|
||||
*
|
||||
* @param array $actions
|
||||
* @param WP_User $user_object
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function user_row_actions( $actions, $user_object ) {
|
||||
$user_id = $user_object->ID;
|
||||
|
||||
// Link to Ultimate Member Profile.
|
||||
$actions['frontend_profile'] = '<a href="' . esc_url( um_user_profile_url( $user_id ) ) . '">' . esc_html__( 'View profile', 'ultimate-member' ) . '</a>';
|
||||
|
||||
// The link for open popup with the registration data submitted through Ultimate Member Registration form.
|
||||
$submitted = get_user_meta( $user_id, 'submitted', true );
|
||||
if ( ! empty( $submitted ) ) {
|
||||
$actions['view_info'] = '<a href="#" data-modal="UM_preview_registration" data-modal-size="smaller"
|
||||
data-dynamic-content="um_admin_review_registration" data-arg1="' . esc_attr( $user_id ) . '" data-arg2="edit_registration">' . esc_html__( 'Info', 'ultimate-member' ) . '</a>';
|
||||
// For new modal below.
|
||||
// $actions['view_info'] = '<a href="#" class="um-preview-registration" data-user_id="' . esc_attr( $user_id ) . '">' . esc_html__( 'Info', 'ultimate-member' ) . '</a>';
|
||||
}
|
||||
|
||||
// Remove row actions for now Administrator role and who cannot view profiles of row's user.
|
||||
if ( ! current_user_can( 'manage_options' ) && ! um_can_view_profile( $user_id ) ) {
|
||||
unset( $actions['frontend_profile'], $actions['view_info'], $actions['view'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the rows actions for the user in wp-admin > Users List Table screen.
|
||||
*
|
||||
* Note: Row actions format is 'key' => 'action_link_html'
|
||||
*
|
||||
* @since 1.3.x
|
||||
* @hook um_admin_user_row_actions
|
||||
*
|
||||
* @param {array} $actions User's row actions.
|
||||
* @param {int} $user_id Row's user ID.
|
||||
*
|
||||
* @return {array} User's row actions.
|
||||
*/
|
||||
return apply_filters( 'um_admin_user_row_actions', $actions, $user_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list with the bulk actions.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function get_user_bulk_actions() {
|
||||
$um_actions = array(
|
||||
'um_approve_membership' => __( 'Approve Membership', 'ultimate-member' ),
|
||||
'um_reject_membership' => __( 'Reject Membership', 'ultimate-member' ),
|
||||
'um_put_as_pending' => __( 'Put as Pending Review', 'ultimate-member' ),
|
||||
'um_resend_activation' => __( 'Resend Activation E-mail', 'ultimate-member' ),
|
||||
'um_deactivate' => __( 'Deactivate', 'ultimate-member' ),
|
||||
'um_reactivate' => __( 'Reactivate', 'ultimate-member' ), // um_reenable
|
||||
);
|
||||
/**
|
||||
* Filters wp-admin > Users List Table bulk actions.
|
||||
*
|
||||
* @since 1.3.x
|
||||
* @since 2.8.7 changed format from `$action_slug => array( 'label' => $action_title )` to `$action_slug => $action_title`
|
||||
* @hook um_admin_bulk_user_actions_hook
|
||||
*
|
||||
* @param {array} $um_actions Users admin actions.
|
||||
*
|
||||
* @return {array} Users admin actions.
|
||||
*
|
||||
* @example <caption>Add `$action_title` to Users List Table bulk actions.</caption>
|
||||
* function um_custom_admin_bulk_user_actions_hook( $um_actions ) {
|
||||
* $um_actions[ $action_slug ] = $action_title;
|
||||
* return $um_actions;
|
||||
* }
|
||||
* add_filter( 'um_admin_bulk_user_actions_hook', 'um_custom_admin_bulk_user_actions_hook' );
|
||||
*/
|
||||
return apply_filters( 'um_admin_bulk_user_actions_hook', $um_actions );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $actions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_bulk_actions( $actions ) {
|
||||
$rolename = UM()->roles()->get_priority_user_role( get_current_user_id() );
|
||||
$role = get_role( $rolename );
|
||||
|
||||
if ( null === $role ) {
|
||||
return $actions;
|
||||
}
|
||||
|
||||
// Add Ultimate Member bulk actions only when the current user has 'edit_users' capability.
|
||||
if ( ! current_user_can( 'edit_users' ) && ! $role->has_cap( 'edit_users' ) ) {
|
||||
return $actions;
|
||||
}
|
||||
|
||||
$actions[ esc_html__( 'Ultimate Member', 'ultimate-member' ) ] = $this->get_user_bulk_actions();
|
||||
return $actions;
|
||||
}
|
||||
|
||||
private function get_statuses_filter_options() {
|
||||
$statuses = UM()->common()->users()->statuses_list();
|
||||
/**
|
||||
* Filters the user statuses added via Ultimate Member plugin.
|
||||
*
|
||||
* Note: Statuses format is 'key' => 'title'
|
||||
*
|
||||
* @since 2.8.7
|
||||
* @hook um_user_statuses_admin_filter_options
|
||||
*
|
||||
* @param {array} $statuses User statuses in Ultimate Member environment.
|
||||
*
|
||||
* @return {array} User statuses.
|
||||
*/
|
||||
return apply_filters( 'um_user_statuses_admin_filter_options', $statuses );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds HTML with the filter by the Ultimate Member status.
|
||||
*
|
||||
* @param string $which Where the callback's hook fired.
|
||||
*/
|
||||
public function add_status_filter( $which ) {
|
||||
if ( 'top' !== $which ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set default statuses if not already done.
|
||||
UM()->setup()->set_default_user_status();
|
||||
|
||||
$id = 'um_user_status';
|
||||
|
||||
// need to add there additional nonce field because WordPress native _wpnonce field isn't visible on the users.php screen then custom actions
|
||||
wp_nonce_field( 'um-bulk-users', '_um_wpnonce', false );
|
||||
|
||||
$statuses = $this->get_statuses_filter_options();
|
||||
?>
|
||||
<div class="alignleft um-filter-by-status">
|
||||
<label class="screen-reader-text" for="<?php echo esc_attr( $id ); ?>"><?php esc_html_e( 'All Statuses', 'ultimate-member' ); ?></label>
|
||||
<select name="<?php echo esc_attr( $id ); ?>" id="<?php echo esc_attr( $id ); ?>">
|
||||
<option value=""><?php esc_html_e( 'All Statuses', 'ultimate-member' ); ?></option>
|
||||
<?php
|
||||
foreach ( $statuses as $k => $v ) {
|
||||
$selected = isset( $_GET[ $id ] ) && sanitize_key( $_GET[ $id ] ) === $k; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- native WordPress nonce is used
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $k ); ?>" <?php selected( $selected ); ?>><?php echo esc_html( $v ); ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php submit_button( __( 'Filter', 'ultimate-member' ), '', 'um_filter_users', false ); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for handling custom bulk actions on the Users List Table
|
||||
*
|
||||
* @param string $sendback URL for redirect after handling bulk action
|
||||
* @param string $current_action Bulk action key
|
||||
* @param array $userids User IDs
|
||||
*
|
||||
* @return string URL for redirect after handling bulk action
|
||||
*/
|
||||
public function handle_bulk_actions( $sendback, $current_action, $userids ) {
|
||||
$um_actions = $this->get_user_bulk_actions();
|
||||
|
||||
if ( ! array_key_exists( $current_action, $um_actions ) ) {
|
||||
return $sendback;
|
||||
}
|
||||
|
||||
// need to handle there additional nonce field because WordPress native _wpnonce field isn't visible on the users.php screen then custom actions
|
||||
check_admin_referer( 'um-bulk-users', '_um_wpnonce' );
|
||||
|
||||
$rolename = UM()->roles()->get_priority_user_role( get_current_user_id() );
|
||||
$role = get_role( $rolename );
|
||||
|
||||
if ( null === $role ) {
|
||||
return $sendback;
|
||||
}
|
||||
|
||||
// Make Ultimate Member bulk actions only when the current user has 'edit_users' capability.
|
||||
if ( ! current_user_can( 'edit_users' ) && ! $role->has_cap( 'edit_users' ) ) {
|
||||
wp_die( esc_html__( 'You do not have enough permissions to do that.', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
$users = array_map( 'absint', $userids );
|
||||
$users = array_diff( $users, array( get_current_user_id() ) ); // cannot make any action related to himself.
|
||||
|
||||
switch ( $current_action ) {
|
||||
case 'um_approve_membership':
|
||||
$approved_count = 0;
|
||||
foreach ( $users as $user_id ) {
|
||||
$res = UM()->common()->users()->approve( $user_id );
|
||||
if ( $res ) {
|
||||
++$approved_count;
|
||||
}
|
||||
}
|
||||
|
||||
$sendback = add_query_arg(
|
||||
array(
|
||||
'approved_count' => $approved_count,
|
||||
'update' => 'um_approved',
|
||||
),
|
||||
$this->set_redirect_uri( $sendback )
|
||||
);
|
||||
break;
|
||||
|
||||
case 'um_reactivate':
|
||||
$reactivated_count = 0;
|
||||
foreach ( $users as $user_id ) {
|
||||
$res = UM()->common()->users()->reactivate( $user_id );
|
||||
if ( $res ) {
|
||||
++$reactivated_count;
|
||||
}
|
||||
}
|
||||
|
||||
$sendback = add_query_arg(
|
||||
array(
|
||||
'reactivated_count' => $reactivated_count,
|
||||
'update' => 'um_reactivated',
|
||||
),
|
||||
$this->set_redirect_uri( $sendback )
|
||||
);
|
||||
break;
|
||||
|
||||
case 'um_reject_membership':
|
||||
$rejected_count = 0;
|
||||
foreach ( $users as $user_id ) {
|
||||
$res = UM()->common()->users()->reject( $user_id );
|
||||
if ( $res ) {
|
||||
++$rejected_count;
|
||||
}
|
||||
}
|
||||
|
||||
$sendback = add_query_arg(
|
||||
array(
|
||||
'rejected_count' => $rejected_count,
|
||||
'update' => 'um_rejected',
|
||||
),
|
||||
$this->set_redirect_uri( $sendback )
|
||||
);
|
||||
break;
|
||||
|
||||
case 'um_deactivate':
|
||||
$deactivated_count = 0;
|
||||
foreach ( $users as $user_id ) {
|
||||
$res = UM()->common()->users()->deactivate( $user_id );
|
||||
if ( $res ) {
|
||||
++$deactivated_count;
|
||||
}
|
||||
}
|
||||
|
||||
$sendback = add_query_arg(
|
||||
array(
|
||||
'deactivated_count' => $deactivated_count,
|
||||
'update' => 'um_deactivate',
|
||||
),
|
||||
$this->set_redirect_uri( $sendback )
|
||||
);
|
||||
break;
|
||||
|
||||
case 'um_put_as_pending':
|
||||
$pending_count = 0;
|
||||
foreach ( $users as $user_id ) {
|
||||
$res = UM()->common()->users()->set_as_pending( $user_id );
|
||||
if ( $res ) {
|
||||
++$pending_count;
|
||||
}
|
||||
}
|
||||
|
||||
$sendback = add_query_arg(
|
||||
array(
|
||||
'pending_count' => $pending_count,
|
||||
'update' => 'um_pending',
|
||||
),
|
||||
$this->set_redirect_uri( $sendback )
|
||||
);
|
||||
break;
|
||||
|
||||
case 'um_resend_activation':
|
||||
$email_pending_count = 0;
|
||||
foreach ( $users as $user_id ) {
|
||||
$res = UM()->common()->users()->send_activation( $user_id, true );
|
||||
if ( $res ) {
|
||||
++$email_pending_count;
|
||||
}
|
||||
}
|
||||
|
||||
$sendback = add_query_arg(
|
||||
array(
|
||||
'resend_activation_count' => $email_pending_count,
|
||||
'update' => 'um_resend_activation',
|
||||
),
|
||||
$this->set_redirect_uri( $sendback )
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
/**
|
||||
* Fires when a custom Ultimate Member bulk action for wp-admin > Users list table should be handled.
|
||||
*
|
||||
* The redirect link should be modified with success or failure feedback
|
||||
* from the action to be used to display feedback to the user.
|
||||
*
|
||||
* The dynamic portion of the hook name, `$current_action`, refers to the current bulk action.
|
||||
* Use together with custom actions added via `um_admin_bulk_user_actions_hook` hook.
|
||||
*
|
||||
* @param {string} $sendback The redirect URL.
|
||||
* @param {array} $userids Selected users in bulk action.
|
||||
*
|
||||
* @return {string} The redirect URL.
|
||||
*
|
||||
* @since 2.8.7
|
||||
* @hook um_handle_bulk_actions-users-{$current_action}
|
||||
*
|
||||
* @example <caption>Handle custom-action and set redirect after it.</caption>
|
||||
* function um_custom_bulk_actions_users( $sendback, $userids ) {
|
||||
* foreach ( $userids as $user_id ) {
|
||||
* // make some action here
|
||||
* }
|
||||
* return add_query_arg( 'action_counter', 'completed action count', $sendback );
|
||||
* }
|
||||
* add_filter( 'um_handle_bulk_actions-users-custom-action', 'um_custom_bulk_actions_users' );
|
||||
*/
|
||||
$sendback = apply_filters( "um_handle_bulk_actions-users-{$current_action}", $sendback, $userids ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
|
||||
break;
|
||||
}
|
||||
|
||||
return $sendback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter WP users by UM Status
|
||||
*
|
||||
* WP_User_Query $query Current instance of WP_User_Query (passed by reference).
|
||||
*/
|
||||
public function filter_users_by_status( $query ) {
|
||||
global $wpdb, $pagenow;
|
||||
|
||||
if ( 'users.php' !== $pagenow || ! is_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( empty( $_REQUEST['um_user_status'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$status = sanitize_key( $_REQUEST['um_user_status'] );
|
||||
|
||||
/**
|
||||
* Filters the marker to disable Ultimate Member default filter by user status.
|
||||
*
|
||||
* @since 2.8.7
|
||||
* @hook um_skip_filter_users_by_status
|
||||
*
|
||||
* @param {bool} $skip Marker to skip Ultimate Member core user filter handler.
|
||||
* @param {string} $status User Status
|
||||
*
|
||||
* @return {array} User's row actions.
|
||||
*/
|
||||
$skip_status_filter = apply_filters( 'um_skip_filter_users_by_status', false, $status );
|
||||
if ( false !== $skip_status_filter ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$query->query_where = str_replace(
|
||||
'WHERE 1=1',
|
||||
$wpdb->prepare(
|
||||
"WHERE 1=1 AND
|
||||
{$wpdb->users}.ID IN (
|
||||
SELECT {$wpdb->usermeta}.user_id
|
||||
FROM $wpdb->usermeta
|
||||
WHERE {$wpdb->usermeta}.meta_key = 'account_status' AND
|
||||
{$wpdb->usermeta}.meta_value = %s
|
||||
)",
|
||||
$status
|
||||
),
|
||||
$query->query_where
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets redirect URI after bulk action
|
||||
*
|
||||
* @param string $uri
|
||||
* @return string
|
||||
*/
|
||||
public function set_redirect_uri( $uri ) {
|
||||
if ( ! empty( $_REQUEST['s'] ) ) {
|
||||
$uri = add_query_arg( 's', sanitize_text_field( $_REQUEST['s'] ), $uri );
|
||||
}
|
||||
|
||||
if ( ! empty( $_REQUEST['um_user_status'] ) ) {
|
||||
$uri = add_query_arg( 'um_user_status', sanitize_key( $_REQUEST['um_user_status'] ), $uri );
|
||||
}
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add query args to list of query variable names to remove.
|
||||
*
|
||||
* @param array $removable_query_args An array of query variable names to remove from a URL
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function add_removable_query_args( $removable_query_args ) {
|
||||
$removable_query_args[] = '_um_wpnonce'; // need to add there additional nonce field because WordPress native _wpnonce field isn't visible on the users.php screen then custom actions
|
||||
$removable_query_args[] = 'approved_count';
|
||||
$removable_query_args[] = 'rejected_count';
|
||||
$removable_query_args[] = 'reactivated_count';
|
||||
$removable_query_args[] = 'deactivated_count';
|
||||
$removable_query_args[] = 'pending_count';
|
||||
$removable_query_args[] = 'resend_activation_count';
|
||||
return $removable_query_args;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,8 +30,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Ajax_Hooks' ) ) {
|
||||
add_action( 'wp_ajax_um_member_directory_default_filter_settings', array( UM()->member_directory(), 'default_filter_settings' ) );
|
||||
|
||||
add_action( 'wp_ajax_um_same_page_update', array( UM()->admin_settings(), 'same_page_update_ajax' ) );
|
||||
|
||||
add_action( 'wp_ajax_um_get_users', array( UM()->users(), 'get_users' ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,42 +33,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Columns' ) ) {
|
||||
add_filter( 'display_post_states', array( &$this, 'add_display_post_states' ), 10, 2 );
|
||||
|
||||
add_filter( 'post_row_actions', array( &$this, 'remove_bulk_actions_um_form_inline' ), 10, 2 );
|
||||
|
||||
add_filter( 'manage_users_columns', array( &$this, 'manage_users_columns' ) );
|
||||
|
||||
add_filter( 'manage_users_custom_column', array( &$this, 'manage_users_custom_column' ), 10, 3 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter: Add column 'Status'
|
||||
*
|
||||
* @param array $columns
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function manage_users_columns( $columns ) {
|
||||
$columns['account_status'] = __( 'Status', 'ultimate-member' );
|
||||
return $columns;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filter: Show column 'Status'
|
||||
*
|
||||
* @param string $val
|
||||
* @param string $column_name
|
||||
* @param int $user_id
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function manage_users_custom_column( $val, $column_name, $user_id ) {
|
||||
if ( $column_name == 'account_status' ) {
|
||||
um_fetch_user( $user_id );
|
||||
$value = um_user( 'account_status_name' );
|
||||
um_reset_user();
|
||||
return $value;
|
||||
}
|
||||
return $val;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -490,9 +490,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
case 'um_settings_updated':
|
||||
$messages[0]['content'] = __( 'Settings have been saved successfully.', 'ultimate-member' );
|
||||
break;
|
||||
case 'um_user_updated':
|
||||
$messages[0]['content'] = __( 'User has been updated.', 'ultimate-member' );
|
||||
break;
|
||||
case 'um_users_updated':
|
||||
$messages[0]['content'] = __( 'Users have been updated.', 'ultimate-member' );
|
||||
break;
|
||||
@@ -502,6 +499,36 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
|
||||
case 'um_secure_restore':
|
||||
$messages[0]['content'] = __( 'Account has been successfully restored.', 'ultimate-member' );
|
||||
break;
|
||||
case 'um_approved':
|
||||
$approved_count = isset( $_REQUEST['approved_count'] ) ? absint( $_REQUEST['approved_count'] ) : 0;
|
||||
|
||||
$messages[0]['content'] = sprintf( _n( '<strong>%s</strong> user has been approved.', '<strong>%s</strong> users have been approved.', $approved_count, 'ultimate-member' ), $approved_count );
|
||||
break;
|
||||
case 'um_reactivated':
|
||||
$reactivated_count = isset( $_REQUEST['reactivated_count'] ) ? absint( $_REQUEST['reactivated_count'] ) : 0;
|
||||
|
||||
$messages[0]['content'] = sprintf( _n( '<strong>%s</strong> user has been reactivated.', '<strong>%s</strong> users have been reactivated.', $reactivated_count, 'ultimate-member' ), $reactivated_count );
|
||||
break;
|
||||
case 'um_rejected':
|
||||
$rejected_count = isset( $_REQUEST['rejected_count'] ) ? absint( $_REQUEST['rejected_count'] ) : 0;
|
||||
|
||||
$messages[0]['content'] = sprintf( _n( '<strong>%s</strong> user has been rejected.', '<strong>%s</strong> users have been rejected.', $rejected_count, 'ultimate-member' ), $rejected_count );
|
||||
break;
|
||||
case 'um_deactivate':
|
||||
$deactivated_count = isset( $_REQUEST['deactivated_count'] ) ? absint( $_REQUEST['deactivated_count'] ) : 0;
|
||||
|
||||
$messages[0]['content'] = sprintf( _n( '<strong>%s</strong> user has been deactivated.', '<strong>%s</strong> users have been deactivated.', $deactivated_count, 'ultimate-member' ), $deactivated_count );
|
||||
break;
|
||||
case 'um_pending':
|
||||
$pending_count = isset( $_REQUEST['pending_count'] ) ? absint( $_REQUEST['pending_count'] ) : 0;
|
||||
|
||||
$messages[0]['content'] = sprintf( _n( '<strong>%s</strong> user has been set as pending admin review.', '<strong>%s</strong> users have been set as pending admin review.', $pending_count, 'ultimate-member' ), $pending_count );
|
||||
break;
|
||||
case 'um_resend_activation':
|
||||
$resend_activation_count = isset( $_REQUEST['resend_activation_count'] ) ? absint( $_REQUEST['resend_activation_count'] ) : 0;
|
||||
|
||||
$messages[0]['content'] = sprintf( _n( 'Activation email for <strong>%s</strong> user has been sent.', 'Activation emails for <strong>%s</strong> users have been sent.', $resend_activation_count, 'ultimate-member' ), $resend_activation_count );
|
||||
break;
|
||||
default:
|
||||
/**
|
||||
* Filters the custom admin notice after um_adm_action.
|
||||
|
||||
@@ -638,7 +638,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
||||
),
|
||||
array(
|
||||
'id' => 'restricted_block_message',
|
||||
'type' => 'textarea',
|
||||
'type' => 'wp_editor',
|
||||
'label' => __( 'Restricted Access Block Message', 'ultimate-member' ),
|
||||
'description' => __( 'This is the message shown to users that do not have permission to view the block\'s content.', 'ultimate-member' ),
|
||||
'conditional' => array( 'restricted_blocks', '=', 1 ),
|
||||
@@ -650,7 +650,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
||||
'sanitize' => 'bool',
|
||||
);
|
||||
$settings_map['restricted_block_message'] = array(
|
||||
'sanitize' => 'textarea',
|
||||
'sanitize' => 'wp_kses',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -769,7 +769,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
||||
'sanitize' => 'bool',
|
||||
),
|
||||
'activation_link_expiry_time' => array(
|
||||
'sanitize' => 'absint',
|
||||
'sanitize' => 'empty_absint',
|
||||
),
|
||||
'account_tab_password' => array(
|
||||
'sanitize' => 'bool',
|
||||
@@ -2784,7 +2784,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
||||
if ( ! empty( $results ) ) {
|
||||
foreach ( $results as $user_id ) {
|
||||
$md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
|
||||
if ( ! empty( $md_data ) ) {
|
||||
if ( ! empty( $md_data ) && is_array( $md_data ) ) {
|
||||
$md_data['profile_photo'] = ! empty( $_POST['um_options']['use_gravatars'] );
|
||||
update_user_meta( $user_id, 'um_member_directory_data', $md_data );
|
||||
}
|
||||
@@ -2834,7 +2834,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
|
||||
if ( ! empty( $results ) ) {
|
||||
foreach ( $results as $user_id ) {
|
||||
$md_data = get_user_meta( $user_id, 'um_member_directory_data', true );
|
||||
if ( ! empty( $md_data ) ) {
|
||||
if ( ! empty( $md_data ) && is_array( $md_data ) ) {
|
||||
$md_data['hide_in_members'] = ( $_POST['um_options']['account_hide_in_directory_default'] === 'No' ) ? false : true;
|
||||
update_user_meta( $user_id, 'um_member_directory_data', $md_data );
|
||||
}
|
||||
|
||||
@@ -1,574 +0,0 @@
|
||||
<?php
|
||||
namespace um\admin\core;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
|
||||
|
||||
/**
|
||||
* Class Admin_Users
|
||||
* @package um\admin\core
|
||||
*/
|
||||
class Admin_Users {
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $custom_role = 'um_role';
|
||||
|
||||
/**
|
||||
* Admin_Users constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'restrict_manage_users', array( &$this, 'restrict_manage_users' ) );
|
||||
|
||||
add_filter( 'user_row_actions', array( &$this, 'user_row_actions' ), 10, 2 );
|
||||
|
||||
add_filter( 'user_has_cap', array( &$this, 'map_caps_by_role' ), 10, 4 );
|
||||
|
||||
add_filter( 'users_list_table_query_args', array( &$this, 'hide_by_caps' ), 1, 1 );
|
||||
|
||||
add_filter( 'pre_user_query', array( &$this, 'sort_by_newest' ) );
|
||||
|
||||
add_filter( 'pre_user_query', array( &$this, 'filter_users_by_status' ) );
|
||||
|
||||
add_filter( 'views_users', array( &$this, 'add_status_links' ) );
|
||||
|
||||
add_action( 'admin_init', array( &$this, 'um_bulk_users_edit' ), 9 );
|
||||
|
||||
add_action( 'um_admin_user_action_hook', array( &$this, 'user_action_hook' ), 10, 1 );
|
||||
}
|
||||
|
||||
public function get_users() {
|
||||
UM()->admin()->check_ajax_nonce();
|
||||
|
||||
$search_request = ! empty( $_REQUEST['search'] ) ? sanitize_text_field( $_REQUEST['search'] ) : '';
|
||||
$page = ! empty( $_REQUEST['page'] ) ? absint( $_REQUEST['page'] ) : 1;
|
||||
$per_page = 20;
|
||||
|
||||
$args = array(
|
||||
'fields' => array( 'ID', 'user_login' ),
|
||||
'paged' => $page,
|
||||
'number' => $per_page,
|
||||
);
|
||||
|
||||
if ( ! empty( $search_request ) ) {
|
||||
$args['search'] = '*' . $search_request . '*';
|
||||
}
|
||||
|
||||
$args = apply_filters( 'um_get_users_list_ajax_args', $args );
|
||||
|
||||
$users_query = new \WP_User_Query( $args );
|
||||
$users = $users_query->get_results();
|
||||
$total_count = $users_query->get_total();
|
||||
|
||||
if ( ! empty( $_REQUEST['avatar'] ) ) {
|
||||
foreach ( $users as $key => $user ) {
|
||||
$url = get_avatar_url( $user->ID );
|
||||
$users[ $key ]->img = $url;
|
||||
}
|
||||
}
|
||||
|
||||
wp_send_json_success(
|
||||
array(
|
||||
'users' => $users,
|
||||
'total_count' => $total_count,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restrict the edit/delete users via wp-admin screen by the UM role capabilities
|
||||
*
|
||||
* @param $allcaps
|
||||
* @param $cap
|
||||
* @param $args
|
||||
* @param $user
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function map_caps_by_role( $allcaps, $cap, $args, $user ) {
|
||||
if ( isset( $cap[0] ) && $cap[0] == 'edit_users' ) {
|
||||
if ( isset( $args[0] ) && isset( $args[1] ) && ! user_can( $args[1], 'administrator' ) && $args[0] == 'edit_user' ) {
|
||||
if ( isset( $args[2] ) && ! UM()->roles()->um_current_user_can( 'edit', $args[2] ) ) {
|
||||
$allcaps[ $cap[0] ] = false;
|
||||
}
|
||||
}
|
||||
} elseif ( isset( $cap[0] ) && $cap[0] == 'delete_users' ) {
|
||||
if ( isset( $args[0] ) && isset( $args[1] ) && ! user_can( $args[1], 'administrator' ) && $args[0] == 'delete_user' ) {
|
||||
if ( isset( $args[2] ) && ! UM()->roles()->um_current_user_can( 'delete', $args[2] ) ) {
|
||||
$allcaps[ $cap[0] ] = false;
|
||||
}
|
||||
}
|
||||
} elseif ( isset( $cap[0] ) && $cap[0] == 'list_users' ) {
|
||||
if ( isset( $args[0] ) && isset( $args[1] ) && ! user_can( $args[1], 'administrator' ) && $args[0] == 'list_users' ) {
|
||||
if ( ! um_user( 'can_view_all' ) ) {
|
||||
$allcaps[ $cap[0] ] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $allcaps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does an action to user asap
|
||||
*
|
||||
* @param string $action
|
||||
*/
|
||||
public function user_action_hook( $action ) {
|
||||
switch ( $action ) {
|
||||
default:
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_admin_custom_hook_{$action}
|
||||
* @description Integration hook on user action
|
||||
* @input_vars
|
||||
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_admin_custom_hook_{$action}', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_admin_custom_hook_{$action}', 'my_admin_custom_hook', 10, 1 );
|
||||
* function my_admin_after_main_notices( $user_id ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( "um_admin_custom_hook_{$action}", UM()->user()->id );
|
||||
break;
|
||||
|
||||
case 'um_put_as_pending':
|
||||
UM()->user()->pending();
|
||||
break;
|
||||
|
||||
case 'um_approve_membership':
|
||||
case 'um_reenable':
|
||||
|
||||
add_filter( 'um_template_tags_patterns_hook', array( UM()->password(), 'add_placeholder' ), 10, 1 );
|
||||
add_filter( 'um_template_tags_replaces_hook', array( UM()->password(), 'add_replace_placeholder' ), 10, 1 );
|
||||
|
||||
UM()->user()->approve();
|
||||
break;
|
||||
|
||||
case 'um_reject_membership':
|
||||
UM()->user()->reject();
|
||||
break;
|
||||
|
||||
case 'um_resend_activation':
|
||||
|
||||
add_filter( 'um_template_tags_patterns_hook', array( UM()->user(), 'add_activation_placeholder' ), 10, 1 );
|
||||
add_filter( 'um_template_tags_replaces_hook', array( UM()->user(), 'add_activation_replace_placeholder' ), 10, 1 );
|
||||
|
||||
UM()->user()->email_pending();
|
||||
break;
|
||||
|
||||
case 'um_deactivate':
|
||||
UM()->user()->deactivate();
|
||||
break;
|
||||
|
||||
case 'um_delete':
|
||||
if ( is_admin() ) {
|
||||
wp_die( __( 'This action is not allowed in backend.', 'ultimate-member' ) );
|
||||
}
|
||||
UM()->user()->delete();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add UM Bulk actions to Users List Table
|
||||
*
|
||||
*/
|
||||
public function restrict_manage_users() {
|
||||
?>
|
||||
<div style="float:right;margin:0 4px">
|
||||
|
||||
<label class="screen-reader-text" for="um_bulk_action"><?php _e( 'UM Action', 'ultimate-member' ); ?></label>
|
||||
|
||||
<select name="um_bulk_action[]" id="um_bulk_action" class="" style="width: 200px">
|
||||
<option value="0"><?php _e( 'UM Action', 'ultimate-member' ); ?></option>
|
||||
<?php echo $this->get_bulk_admin_actions(); ?>
|
||||
</select>
|
||||
|
||||
<input name="um_bulkedit" id="um_bulkedit" class="button" value="<?php esc_attr_e( 'Apply', 'ultimate-member' ); ?>" type="submit" />
|
||||
|
||||
</div>
|
||||
|
||||
<?php if ( ! empty( $_REQUEST['um_status'] ) ) { ?>
|
||||
<input type="hidden" name="um_status" id="um_status" value="<?php echo esc_attr( sanitize_key( $_REQUEST['um_status'] ) );?>"/>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get UM bulk actions HTML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_bulk_admin_actions() {
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_admin_bulk_user_actions_hook
|
||||
* @description Admin Users List Table bulk actions
|
||||
* @input_vars
|
||||
* [{"var":"$actions","type":"array","desc":"User List Table bulk actions"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_admin_bulk_user_actions_hook', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_admin_bulk_user_actions_hook', 'my_admin_bulk_user_actions', 10, 1 );
|
||||
* function my_admin_bulk_user_actions( $actions ) {
|
||||
* // your code here
|
||||
* $actions['my-custom-bulk'] = array(
|
||||
* 'label' => 'My Custom Bulk Action'
|
||||
* );
|
||||
* return $actions;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$actions = apply_filters( 'um_admin_bulk_user_actions_hook', array(
|
||||
'um_approve_membership' => array(
|
||||
'label' => __( 'Approve Membership', 'ultimate-member' )
|
||||
),
|
||||
'um_reject_membership' => array(
|
||||
'label' => __( 'Reject Membership', 'ultimate-member' )
|
||||
),
|
||||
'um_put_as_pending' => array(
|
||||
'label' => __( 'Put as Pending Review', 'ultimate-member' )
|
||||
),
|
||||
'um_resend_activation' => array(
|
||||
'label' => __( 'Resend Activation Email', 'ultimate-member' )
|
||||
),
|
||||
'um_deactivate' => array(
|
||||
'label' => __( 'Deactivate', 'ultimate-member' )
|
||||
),
|
||||
'um_reenable' => array(
|
||||
'label' => __( 'Reactivate', 'ultimate-member' )
|
||||
)
|
||||
) );
|
||||
|
||||
$output = '';
|
||||
foreach ( $actions as $id => $action_data ) {
|
||||
$output .= '<option value="' . $id . '" '. disabled( isset( $arr['disabled'] ), true, false ) . '>' . $action_data['label'] . '</option>';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom row actions for users page
|
||||
*
|
||||
* @param array $actions
|
||||
* @param $user_object \WP_User
|
||||
* @return array
|
||||
*/
|
||||
public function user_row_actions( $actions, $user_object ) {
|
||||
$user_id = $user_object->ID;
|
||||
|
||||
$actions['frontend_profile'] = '<a href="' . esc_url( um_user_profile_url( $user_id ) ) . '">' . __( 'View profile', 'ultimate-member' ) . '</a>';
|
||||
|
||||
$submitted = get_user_meta( $user_id, 'submitted', true );
|
||||
if ( ! empty( $submitted ) ) {
|
||||
$actions['view_info'] = '<a href="javascript:void(0);" data-modal="UM_preview_registration" data-modal-size="smaller"
|
||||
data-dynamic-content="um_admin_review_registration" data-arg1="' . esc_attr( $user_id ) . '" data-arg2="edit_registration">' . __( 'Info', 'ultimate-member' ) . '</a>';
|
||||
}
|
||||
|
||||
if ( ! current_user_can( 'administrator' ) ) {
|
||||
if ( ! um_can_view_profile( $user_id ) ) {
|
||||
unset( $actions['frontend_profile'] );
|
||||
unset( $actions['view_info'] );
|
||||
unset( $actions['view'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_admin_user_row_actions
|
||||
* @description Admin views array
|
||||
* @input_vars
|
||||
* [{"var":"$actions","type":"array","desc":"User List Table actions"},
|
||||
* {"var":"$user_id","type":"int","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_admin_user_row_actions', 'function_name', 10, 2 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_admin_user_row_actions', 'my_admin_user_row_actions', 10, 2 );
|
||||
* function my_admin_user_row_actions( $actions, $user_id ) {
|
||||
* // your code here
|
||||
* return $actions;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$actions = apply_filters( 'um_admin_user_row_actions', $actions, $user_id );
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change default sorting at WP Users list table
|
||||
*
|
||||
* @param array $args
|
||||
* @return array
|
||||
*/
|
||||
public function hide_by_caps( $args ) {
|
||||
if ( ! current_user_can( 'administrator' ) ) {
|
||||
$can_view_roles = um_user( 'can_view_roles' );
|
||||
if ( um_user( 'can_view_all' ) && ! empty( $can_view_roles ) ) {
|
||||
$args['role__in'] = $can_view_roles;
|
||||
}
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change default sorting at WP Users list table
|
||||
*
|
||||
* @param $query
|
||||
* @return mixed
|
||||
*/
|
||||
public function sort_by_newest( $query ) {
|
||||
global $pagenow;
|
||||
|
||||
if ( is_admin() && 'users.php' === $pagenow ) {
|
||||
if ( ! isset( $_REQUEST['orderby'] ) ) {
|
||||
$query->query_vars['order'] = 'desc';
|
||||
$query->query_orderby = ' ORDER BY user_registered ' . ( 'desc' === $query->query_vars['order'] ? 'desc ' : 'asc ' ); //set sort order
|
||||
}
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter WP users by UM Status
|
||||
*
|
||||
* @param $query
|
||||
* @return mixed
|
||||
*/
|
||||
public function filter_users_by_status( $query ) {
|
||||
global $wpdb, $pagenow;
|
||||
if ( is_admin() && 'users.php' === $pagenow && ! empty( $_REQUEST['um_status'] ) ) {
|
||||
|
||||
$status = sanitize_key( $_REQUEST['um_status'] );
|
||||
|
||||
if ( 'needs-verification' === $status ) {
|
||||
$query->query_where = str_replace('WHERE 1=1',
|
||||
"WHERE 1=1 AND {$wpdb->users}.ID IN (
|
||||
SELECT {$wpdb->usermeta}.user_id FROM $wpdb->usermeta
|
||||
WHERE {$wpdb->usermeta}.meta_key = '_um_verified'
|
||||
AND {$wpdb->usermeta}.meta_value = 'pending')",
|
||||
$query->query_where
|
||||
);
|
||||
} else {
|
||||
$query->query_where = str_replace('WHERE 1=1',
|
||||
"WHERE 1=1 AND {$wpdb->users}.ID IN (
|
||||
SELECT {$wpdb->usermeta}.user_id FROM $wpdb->usermeta
|
||||
WHERE {$wpdb->usermeta}.meta_key = 'account_status'
|
||||
AND {$wpdb->usermeta}.meta_value = '{$status}')",
|
||||
$query->query_where
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add status links to WP Users List Table
|
||||
*
|
||||
* @param $views
|
||||
* @return array
|
||||
*/
|
||||
public function add_status_links( $views ) {
|
||||
remove_filter( 'pre_user_query', array( &$this, 'filter_users_by_status' ) );
|
||||
|
||||
$old_views = $views;
|
||||
$views = array();
|
||||
|
||||
if ( ! isset( $_REQUEST['role'] ) && ! isset( $_REQUEST['um_status'] ) ) {
|
||||
$views['all'] = '<a href="' . admin_url( 'users.php' ) . '" class="current">' . __( 'All', 'ultimate-member' ) . ' <span class="count">(' . UM()->query()->count_users() . ')</span></a>';
|
||||
} else {
|
||||
$views['all'] = '<a href="' . admin_url( 'users.php' ) . '">' . __( 'All', 'ultimate-member' ) . ' <span class="count">(' . UM()->query()->count_users() . ')</span></a>';
|
||||
}
|
||||
|
||||
$status = array(
|
||||
'approved' => __( 'Approved', 'ultimate-member' ),
|
||||
'awaiting_admin_review' => __( 'Pending review', 'ultimate-member' ),
|
||||
'awaiting_email_confirmation' => __( 'Waiting email confirmation', 'ultimate-member' ),
|
||||
'inactive' => __( 'Inactive', 'ultimate-member' ),
|
||||
'rejected' => __( 'Rejected', 'ultimate-member' ),
|
||||
);
|
||||
|
||||
// set default statuses if not already done
|
||||
UM()->setup()->set_default_user_status();
|
||||
|
||||
foreach ( $status as $k => $v ) {
|
||||
if ( isset( $_REQUEST['um_status'] ) && sanitize_key( $_REQUEST['um_status'] ) === $k ) {
|
||||
$current = 'class="current"';
|
||||
} else {
|
||||
$current = '';
|
||||
}
|
||||
|
||||
$views[ $k ] = '<a href="' . esc_url( admin_url( 'users.php' ) . '?um_status=' . $k ) . '" ' . $current . '>' . $v . ' <span class="count">(' . UM()->query()->count_users_by_status( $k ) . ')</span></a>';
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type filter
|
||||
* @title um_admin_views_users
|
||||
* @description Admin views array
|
||||
* @input_vars
|
||||
* [{"var":"$views","type":"array","desc":"User Views"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_filter( 'um_admin_views_users', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_filter( 'um_admin_views_users', 'my_admin_views_users', 10, 1 );
|
||||
* function my_admin_views_users( $views ) {
|
||||
* // your code here
|
||||
* return $views;
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
$views = apply_filters( 'um_admin_views_users', $views );
|
||||
|
||||
// remove all filters
|
||||
unset( $old_views['all'] );
|
||||
|
||||
// add separator
|
||||
$views['subsep'] = '<span></span>';
|
||||
|
||||
// merge views
|
||||
foreach ( $old_views as $key => $view ) {
|
||||
$views[ $key ] = $view;
|
||||
}
|
||||
|
||||
// hide filters with not accessible roles
|
||||
if ( ! current_user_can( 'administrator' ) ) {
|
||||
$wp_roles = wp_roles();
|
||||
$can_view_roles = um_user( 'can_view_roles' );
|
||||
if ( ! empty( $can_view_roles ) ) {
|
||||
foreach ( $wp_roles->get_names() as $this_role => $name ) {
|
||||
if ( ! in_array( $this_role, $can_view_roles, true ) ) {
|
||||
unset( $views[ $this_role ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $views;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk user editing actions
|
||||
*/
|
||||
public function um_bulk_users_edit() {
|
||||
// bulk edit users
|
||||
if ( ! empty( $_REQUEST['users'] ) && ! empty( $_REQUEST['um_bulkedit'] ) && ! empty( $_REQUEST['um_bulk_action'] ) ) {
|
||||
|
||||
$rolename = UM()->roles()->get_priority_user_role( get_current_user_id() );
|
||||
$role = get_role( $rolename );
|
||||
|
||||
if ( ! current_user_can( 'edit_users' ) && ! $role->has_cap( 'edit_users' ) ) {
|
||||
wp_die( esc_html__( 'You do not have enough permissions to do that.', 'ultimate-member' ) );
|
||||
}
|
||||
|
||||
check_admin_referer( 'bulk-users' );
|
||||
|
||||
$users = array_map( 'absint', (array) $_REQUEST['users'] );
|
||||
$bulk_action = current( array_filter( $_REQUEST['um_bulk_action'] ) );
|
||||
|
||||
foreach ( $users as $user_id ) {
|
||||
UM()->user()->set( $user_id );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_admin_user_action_hook
|
||||
* @description Action on bulk user action
|
||||
* @input_vars
|
||||
* [{"var":"$bulk_action","type":"string","desc":"Bulk Action"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_admin_user_action_hook{$action}', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_admin_user_action_hook', 'my_admin_user_action', 10, 1 );
|
||||
* function my_admin_user_action( $bulk_action ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_admin_user_action_hook', $bulk_action );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_admin_user_action_{$bulk_action}_hook
|
||||
* @description Action on bulk user action
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_admin_user_action_{$bulk_action}_hook', 'function_name', 10 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_admin_user_action_{$bulk_action}_hook', 'my_admin_user_action', 10 );
|
||||
* function my_admin_user_action() {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( "um_admin_user_action_{$bulk_action}_hook" );
|
||||
}
|
||||
|
||||
$uri = $this->set_redirect_uri( admin_url( 'users.php' ) );
|
||||
$uri = add_query_arg( 'update', 'um_users_updated', $uri );
|
||||
|
||||
wp_redirect( $uri );
|
||||
exit;
|
||||
} elseif ( ! empty( $_REQUEST['um_bulkedit'] ) ) {
|
||||
|
||||
$uri = $this->set_redirect_uri( admin_url( 'users.php' ) );
|
||||
wp_redirect( $uri );
|
||||
exit;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets redirect URI after bulk action
|
||||
*
|
||||
* @param string $uri
|
||||
* @return string
|
||||
*/
|
||||
public function set_redirect_uri( $uri ) {
|
||||
|
||||
if ( ! empty( $_REQUEST['s'] ) ) {
|
||||
$uri = add_query_arg( 's', sanitize_text_field( $_REQUEST['s'] ), $uri );
|
||||
}
|
||||
|
||||
if ( ! empty( $_REQUEST['um_status'] ) ) {
|
||||
$uri = add_query_arg( 'um_status', sanitize_key( $_REQUEST['um_status'] ), $uri );
|
||||
}
|
||||
|
||||
return $uri;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,70 +3,70 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<table id="um-users-overview-table">
|
||||
<tr>
|
||||
<td>
|
||||
<span>
|
||||
<a class="count" href="<?php echo esc_url( admin_url( 'users.php' ) ); ?>">
|
||||
<?php echo UM()->query()->count_users(); ?>
|
||||
<?php echo esc_html( UM()->query()->count_users() ); ?>
|
||||
</a>
|
||||
<a href="<?php echo esc_url( admin_url( 'users.php' ) ); ?>">
|
||||
<?php _e( 'Users', 'ultimate-member' ); ?>
|
||||
<?php esc_html_e( 'Users', 'ultimate-member' ); ?>
|
||||
</a>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span>
|
||||
<a class="count" href="<?php echo esc_url( admin_url( 'users.php?um_status=awaiting_admin_review' ) ); ?>">
|
||||
<?php echo UM()->query()->count_users_by_status( 'awaiting_admin_review' ); ?>
|
||||
</a>
|
||||
<a href="<?php echo esc_url( admin_url( 'users.php?um_status=awaiting_admin_review' ) ); ?>" class="warning">
|
||||
<?php _e( 'Pending Review', 'ultimate-member' ); ?>
|
||||
</a>
|
||||
<a class="count" href="<?php echo esc_url( admin_url( 'users.php?um_user_status=awaiting_admin_review' ) ); ?>">
|
||||
<?php echo esc_html( UM()->query()->count_users_by_status( 'awaiting_admin_review' ) ); ?>
|
||||
</a>
|
||||
<a href="<?php echo esc_url( admin_url( 'users.php?um_user_status=awaiting_admin_review' ) ); ?>" class="warning">
|
||||
<?php esc_html_e( 'Pending Review', 'ultimate-member' ); ?>
|
||||
</a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span>
|
||||
<a class="count" href="<?php echo esc_url( admin_url( 'users.php?um_status=approved' ) ); ?>">
|
||||
<?php echo UM()->query()->count_users_by_status( 'approved' ); ?>
|
||||
</a>
|
||||
<a href="<?php echo esc_url( admin_url( 'users.php?um_status=approved' ) ); ?>">
|
||||
<?php _e( 'Approved', 'ultimate-member' ); ?>
|
||||
</a>
|
||||
<a class="count" href="<?php echo esc_url( admin_url( 'users.php?um_user_status=approved' ) ); ?>">
|
||||
<?php echo esc_html( UM()->query()->count_users_by_status( 'approved' ) ); ?>
|
||||
</a>
|
||||
<a href="<?php echo esc_url( admin_url( 'users.php?um_user_status=approved' ) ); ?>">
|
||||
<?php esc_html_e( 'Approved', 'ultimate-member' ); ?>
|
||||
</a>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span>
|
||||
<a class="count" href="<?php echo esc_url( admin_url( 'users.php?um_status=awaiting_email_confirmation' ) ); ?>">
|
||||
<?php echo UM()->query()->count_users_by_status( 'awaiting_email_confirmation' ); ?>
|
||||
</a>
|
||||
<a href="<?php echo esc_url( admin_url( 'users.php?um_status=awaiting_email_confirmation' ) ); ?>" class="warning">
|
||||
<?php _e( 'Awaiting Email Confirmation', 'ultimate-member' ); ?>
|
||||
</a>
|
||||
<a class="count" href="<?php echo esc_url( admin_url( 'users.php?um_user_status=awaiting_email_confirmation' ) ); ?>">
|
||||
<?php echo esc_html( UM()->query()->count_users_by_status( 'awaiting_email_confirmation' ) ); ?>
|
||||
</a>
|
||||
<a href="<?php echo esc_url( admin_url( 'users.php?um_user_status=awaiting_email_confirmation' ) ); ?>" class="warning">
|
||||
<?php esc_html_e( 'Awaiting Email Confirmation', 'ultimate-member' ); ?>
|
||||
</a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span>
|
||||
<a class="count" href="<?php echo esc_url( admin_url( 'users.php?um_status=rejected' ) ); ?>">
|
||||
<?php echo UM()->query()->count_users_by_status( 'rejected' ); ?>
|
||||
</a>
|
||||
<a href="<?php echo esc_url( admin_url( 'users.php?um_status=rejected' ) ); ?>">
|
||||
<?php _e( 'Rejected', 'ultimate-member' ); ?>
|
||||
</a></span>
|
||||
<a class="count" href="<?php echo esc_url( admin_url( 'users.php?um_user_status=rejected' ) ); ?>">
|
||||
<?php echo esc_html( UM()->query()->count_users_by_status( 'rejected' ) ); ?>
|
||||
</a>
|
||||
<a href="<?php echo esc_url( admin_url( 'users.php?um_user_status=rejected' ) ); ?>">
|
||||
<?php esc_html_e( 'Rejected', 'ultimate-member' ); ?>
|
||||
</a>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span>
|
||||
<a class="count" href="<?php echo esc_url( admin_url( 'users.php?um_status=inactive' ) ); ?>">
|
||||
<?php echo UM()->query()->count_users_by_status( 'inactive' ); ?>
|
||||
</a>
|
||||
<a href="<?php echo esc_url( admin_url( 'users.php?um_status=inactive' ) ); ?>">
|
||||
<?php _e( 'Inactive', 'ultimate-member' ); ?>
|
||||
</a>
|
||||
<a class="count" href="<?php echo esc_url( admin_url( 'users.php?um_user_status=inactive' ) ); ?>">
|
||||
<?php echo esc_html( UM()->query()->count_users_by_status( 'inactive' ) ); ?>
|
||||
</a>
|
||||
<a href="<?php echo esc_url( admin_url( 'users.php?um_user_status=inactive' ) ); ?>">
|
||||
<?php esc_html_e( 'Inactive', 'ultimate-member' ); ?>
|
||||
</a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1,61 +1,66 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
|
||||
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
$role = $object['data'];
|
||||
?>
|
||||
<div class="um-admin-metabox">
|
||||
<?php $role = $object['data'];
|
||||
|
||||
UM()->admin_forms( array(
|
||||
'class' => 'um-role-admin um-half-column',
|
||||
'prefix_id' => 'role',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_can_access_wpadmin',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Can access wp-admin?', 'ultimate-member' ),
|
||||
'tooltip' => __( 'The core admin role must always have access to wp-admin / WordPress backend', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_can_access_wpadmin'] ) ? $role['_um_can_access_wpadmin'] : 0,
|
||||
<?php
|
||||
UM()->admin_forms(
|
||||
array(
|
||||
'class' => 'um-role-admin um-half-column',
|
||||
'prefix_id' => 'role',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_can_access_wpadmin',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Can access wp-admin?', 'ultimate-member' ),
|
||||
'tooltip' => __( 'The core admin role must always have access to wp-admin / WordPress backend', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_can_access_wpadmin'] ) ? $role['_um_can_access_wpadmin'] : 0,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_can_not_see_adminbar',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Force hiding adminbar in frontend?', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Mark this option if you need to hide the adminbar on frontend for this role', 'ultimate-member' ),
|
||||
'value' => isset( $role['_um_can_not_see_adminbar'] ) ? $role['_um_can_not_see_adminbar'] : 1,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_can_edit_everyone',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Can edit other member accounts?', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Allow this role to edit accounts of other members', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_can_edit_everyone'] ) ? $role['_um_can_edit_everyone'] : 0,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_can_edit_roles',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Can edit these user roles only', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Multiple selections of which roles this role can edit, none selected to allow this role to edit all member roles.', 'ultimate-member' ),
|
||||
'options' => UM()->roles()->get_roles(),
|
||||
'multi' => true,
|
||||
'value' => ! empty( $role['_um_can_edit_roles'] ) ? $role['_um_can_edit_roles'] : array(),
|
||||
'conditional' => array( '_um_can_edit_everyone', '=', '1' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_can_delete_everyone',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Can delete other member accounts?', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Allow this role to delete other user accounts.', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_can_delete_everyone'] ) ? $role['_um_can_delete_everyone'] : 0,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_can_delete_roles',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Can delete these user roles only', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Multiple selections of which roles this role can delete, none selected to allow this role to delete all member roles', 'ultimate-member' ),
|
||||
'options' => UM()->roles()->get_roles(),
|
||||
'multi' => true,
|
||||
'value' => ! empty( $role['_um_can_delete_roles'] ) ? $role['_um_can_delete_roles'] : array(),
|
||||
'conditional' => array( '_um_can_delete_everyone', '=', '1' ),
|
||||
)
|
||||
),
|
||||
array(
|
||||
'id' => '_um_can_not_see_adminbar',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Force hiding adminbar in frontend?', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Mark this option if you need to hide the adminbar on frontend for this role', 'ultimate-member' ),
|
||||
'value' => isset( $role['_um_can_not_see_adminbar'] ) ? $role['_um_can_not_see_adminbar'] : 1,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_can_edit_everyone',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Can edit other member accounts?', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Allow this role to edit accounts of other members', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_can_edit_everyone'] ) ? $role['_um_can_edit_everyone'] : 0,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_can_edit_roles',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Can edit these user roles only', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Which roles that role can edit, choose none to allow role to edit all member roles', 'ultimate-member' ),
|
||||
'options' => UM()->roles()->get_roles(),
|
||||
'multi' => true,
|
||||
'value' => ! empty( $role['_um_can_edit_roles'] ) ? $role['_um_can_edit_roles'] : array(),
|
||||
'conditional' => array( '_um_can_edit_everyone', '=', '1' )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_can_delete_everyone',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Can delete other member accounts?', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Allow this role to delete other user accounts.', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_can_delete_everyone'] ) ? $role['_um_can_delete_everyone'] : 0,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_can_delete_roles',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Can delete these user roles only', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Which roles that role can edit, choose none to allow role to edit all member roles', 'ultimate-member' ),
|
||||
'options' => UM()->roles()->get_roles(),
|
||||
'multi' => true,
|
||||
'value' => ! empty( $role['_um_can_delete_roles'] ) ? $role['_um_can_delete_roles'] : array(),
|
||||
'conditional' => array( '_um_can_delete_everyone', '=', '1' )
|
||||
)
|
||||
)
|
||||
) )->render_form(); ?>
|
||||
)->render_form();
|
||||
?>
|
||||
</div>
|
||||
|
||||
@@ -1,61 +1,65 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
|
||||
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
$role = $object['data'];
|
||||
?>
|
||||
<div class="um-admin-metabox">
|
||||
<?php $role = $object['data'];
|
||||
|
||||
UM()->admin_forms( array(
|
||||
'class' => 'um-role-profile um-half-column',
|
||||
'prefix_id' => 'role',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_can_view_all',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Can view other member profiles?', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Can this role view all member profiles?', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_can_view_all'] ) ? $role['_um_can_view_all'] : 0,
|
||||
<?php
|
||||
UM()->admin_forms(
|
||||
array(
|
||||
'class' => 'um-role-profile um-half-column',
|
||||
'prefix_id' => 'role',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_can_view_all',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Can view other member profiles?', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Can this role view all member profiles?', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_can_view_all'] ) ? $role['_um_can_view_all'] : 0,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_can_view_roles',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Can view these user roles only', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Multiple selections of which roles this role can view, none selected to allow this role to view all member roles.', 'ultimate-member' ),
|
||||
'options' => UM()->roles()->get_roles(),
|
||||
'multi' => true,
|
||||
'value' => ! empty( $role['_um_can_view_roles'] ) ? $role['_um_can_view_roles'] : array(),
|
||||
'conditional' => array( '_um_can_view_all', '=', '1' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_can_make_private_profile',
|
||||
'type' => 'checkbox',
|
||||
'name' => '_um_can_make_private_profile',
|
||||
'label' => __( 'Can make their profile private?', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Can this role make their profile private?', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_can_make_private_profile'] ) ? $role['_um_can_make_private_profile'] : 0,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_can_access_private_profile',
|
||||
'type' => 'checkbox',
|
||||
'name' => '_um_can_access_private_profile',
|
||||
'label' => __( 'Can view/access private profiles?', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Can this role view private profiles?', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_can_access_private_profile'] ) ? $role['_um_can_access_private_profile'] : 0,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_noindex',
|
||||
'type' => 'select',
|
||||
'size' => 'medium',
|
||||
'name' => '_um_profile_noindex',
|
||||
'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Hides the profile page for robots. The default value depends on the General > Users setting.', 'ultimate-member' ),
|
||||
'options' => array(
|
||||
'' => __( 'Default', 'ultimate-member' ),
|
||||
'0' => __( 'No', 'ultimate-member' ),
|
||||
'1' => __( 'Yes', 'ultimate-member' ),
|
||||
),
|
||||
'value' => array_key_exists( '_um_profile_noindex', $role ) ? $role['_um_profile_noindex'] : '',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_can_view_roles',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Can view these user roles only', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Which roles that role can view, choose none to allow role to view all member roles', 'ultimate-member' ),
|
||||
'options' => UM()->roles()->get_roles(),
|
||||
'multi' => true,
|
||||
'value' => ! empty( $role['_um_can_view_roles'] ) ? $role['_um_can_view_roles'] : array(),
|
||||
'conditional' => array( '_um_can_view_all', '=', '1' )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_can_make_private_profile',
|
||||
'type' => 'checkbox',
|
||||
'name' => '_um_can_make_private_profile',
|
||||
'label' => __( 'Can make their profile private?', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Can this role make their profile private?', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_can_make_private_profile'] ) ? $role['_um_can_make_private_profile'] : 0,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_can_access_private_profile',
|
||||
'type' => 'checkbox',
|
||||
'name' => '_um_can_access_private_profile',
|
||||
'label' => __( 'Can view/access private profiles?', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Can this role view private profiles?', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_can_access_private_profile'] ) ? $role['_um_can_access_private_profile'] : 0,
|
||||
),
|
||||
array(
|
||||
'id' => '_um_profile_noindex',
|
||||
'type' => 'select',
|
||||
'size' => 'medium',
|
||||
'name' => '_um_profile_noindex',
|
||||
'label' => __( 'Avoid indexing profile by search engines', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Hides the profile page for robots. The default value depends on the General > Users setting.', 'ultimate-member' ),
|
||||
'options' => [
|
||||
'' => __( 'Default', 'ultimate-member' ),
|
||||
'0' => __( 'No', 'ultimate-member' ),
|
||||
'1' => __( 'Yes', 'ultimate-member' ),
|
||||
],
|
||||
'value' => array_key_exists( '_um_profile_noindex', $role ) ? $role['_um_profile_noindex'] : '',
|
||||
)
|
||||
)
|
||||
) )->render_form(); ?>
|
||||
|
||||
</div>
|
||||
)->render_form();
|
||||
?>
|
||||
</div>
|
||||
|
||||
@@ -1,113 +1,121 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
|
||||
|
||||
<?php
|
||||
/**
|
||||
* @var array $object Role object
|
||||
*/
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
$role_data = $object['data'];
|
||||
?>
|
||||
|
||||
<div class="um-admin-metabox">
|
||||
<?php $role = $object['data'];
|
||||
|
||||
UM()->admin_forms( array(
|
||||
'class' => 'um-role-register um-half-column',
|
||||
'prefix_id' => 'role',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_status',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Registration Status', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Select the status you would like this user role to have after they register on your site', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_status'] ) ? __( $role['_um_status'] , 'ultimate-member' ) : array(),
|
||||
'options' => array(
|
||||
'approved' => __( 'Auto Approve', 'ultimate-member' ),
|
||||
'checkmail' => __( 'Require Email Activation', 'ultimate-member' ),
|
||||
'pending' => __( 'Require Admin Review', 'ultimate-member' )
|
||||
<?php
|
||||
UM()->admin_forms(
|
||||
array(
|
||||
'class' => 'um-role-register um-half-column',
|
||||
'prefix_id' => 'role',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => '_um_status',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Registration Status', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Select the status you would like this user role to have after they register on your site', 'ultimate-member' ),
|
||||
'value' => ! empty( $role_data['_um_status'] ) ? $role_data['_um_status'] : array(),
|
||||
'options' => array(
|
||||
'approved' => __( 'Auto Approve', 'ultimate-member' ),
|
||||
'checkmail' => __( 'Require Email Activation', 'ultimate-member' ),
|
||||
'pending' => __( 'Require Admin Review', 'ultimate-member' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_auto_approve_act',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Action to be taken after registration', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Select what action is taken after a person registers on your site. Depending on the status you can redirect them to their profile, a custom url or show a custom message', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_auto_approve_act'] ) ? __( $role['_um_auto_approve_act'], 'ultimate-member' ) : array(),
|
||||
'options' => array(
|
||||
'redirect_profile' => __( 'Redirect to profile', 'ultimate-member' ),
|
||||
'redirect_url' => __( 'Redirect to URL', 'ultimate-member' ),
|
||||
array(
|
||||
'id' => '_um_auto_approve_act',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Action to be taken after registration', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Select what action is taken after a person registers on your site. Depending on the status you can redirect them to their profile, a custom url or show a custom message', 'ultimate-member' ),
|
||||
'value' => ! empty( $role_data['_um_auto_approve_act'] ) ? $role_data['_um_auto_approve_act'] : array(),
|
||||
'options' => array(
|
||||
'redirect_profile' => __( 'Redirect to profile', 'ultimate-member' ),
|
||||
'redirect_url' => __( 'Redirect to URL', 'ultimate-member' ),
|
||||
),
|
||||
'conditional' => array( '_um_status', '=', 'approved' ),
|
||||
),
|
||||
'conditional' => array( '_um_status', '=', 'approved' )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_auto_approve_url',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Set Custom Redirect URL', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_auto_approve_url'] ) ? __( $role['_um_auto_approve_url'], 'ultimate-member' ) : '',
|
||||
'conditional' => array( '_um_auto_approve_act', '=', 'redirect_url' )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_login_email_activate',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Login user after validating the activation link?', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Login the user after validating the activation link', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_login_email_activate'] ) ? __( $role['_um_login_email_activate'], 'ultimate-member' ) : 0,
|
||||
'conditional' => array( '_um_status', '=', 'checkmail' )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_checkmail_action',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Action to be taken after registration', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Select what action is taken after a person registers on your site. Depending on the status you can redirect them to their profile, a custom url or show a custom message', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_checkmail_action'] ) ? __( $role['_um_checkmail_action'], 'ultimate-member' ) : array(),
|
||||
'options' => array(
|
||||
'show_message' => __( 'Show custom message', 'ultimate-member' ),
|
||||
'redirect_url' => __( 'Redirect to URL', 'ultimate-member' ),
|
||||
array(
|
||||
'id' => '_um_auto_approve_url',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Set Custom Redirect URL', 'ultimate-member' ),
|
||||
'value' => ! empty( $role_data['_um_auto_approve_url'] ) ? $role_data['_um_auto_approve_url'] : '',
|
||||
'conditional' => array( '_um_auto_approve_act', '=', 'redirect_url' ),
|
||||
),
|
||||
'conditional' => array( '_um_status', '=', 'checkmail' )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_checkmail_message',
|
||||
'type' => 'textarea',
|
||||
'label' => __( 'Personalize the custom message', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_checkmail_message'] ) ? __( $role['_um_checkmail_message'], 'ultimate-member' ) : __('Thank you for registering. Before you can login we need you to activate your account by clicking the activation link in the email we just sent you.','ultimate-member'),
|
||||
'conditional' => array( '_um_checkmail_action', '=', 'show_message' )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_checkmail_url',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Set Custom Redirect URL', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_checkmail_url'] ) ? __( $role['_um_checkmail_url'], 'ultimate-member' ) : '',
|
||||
'conditional' => array( '_um_checkmail_action', '=', 'redirect_url' )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_url_email_activate',
|
||||
'type' => 'text',
|
||||
'label' => __( 'URL redirect after email activation', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If you want users to go to a specific page other than login page after email activation, enter the URL here.', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_url_email_activate'] ) ? __( $role['_um_url_email_activate'], 'ultimate-member' ) : '',
|
||||
'conditional' => array( '_um_status', '=', 'checkmail' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_pending_action',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Action to be taken after registration', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Select what action is taken after a person registers on your site. Depending on the status you can redirect them to their profile, a custom url or show a custom message', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_pending_action'] ) ? __( $role['_um_pending_action'], 'ultimate-member' ) : array(),
|
||||
'options' => array(
|
||||
'show_message' => __( 'Show custom message', 'ultimate-member' ),
|
||||
'redirect_url' => __( 'Redirect to URL', 'ultimate-member' ),
|
||||
array(
|
||||
'id' => '_um_checkmail_action',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Action to be taken after registration', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Select what action is taken after a person registers on your site. Depending on the status you can redirect them to their profile, a custom url or show a custom message', 'ultimate-member' ),
|
||||
'value' => ! empty( $role_data['_um_checkmail_action'] ) ? $role_data['_um_checkmail_action'] : array(),
|
||||
'options' => array(
|
||||
'show_message' => __( 'Show custom message', 'ultimate-member' ),
|
||||
'redirect_url' => __( 'Redirect to URL', 'ultimate-member' ),
|
||||
),
|
||||
'conditional' => array( '_um_status', '=', 'checkmail' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_checkmail_message',
|
||||
'type' => 'textarea',
|
||||
'label' => __( 'Personalize the custom message', 'ultimate-member' ),
|
||||
'value' => ! empty( $role_data['_um_checkmail_message'] ) ? $role_data['_um_checkmail_message'] : __( 'Thank you for registering. Before you can login we need you to activate your account by clicking the activation link in the email we just sent you.', 'ultimate-member' ),
|
||||
'conditional' => array( '_um_checkmail_action', '=', 'show_message' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_checkmail_url',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Set Custom Redirect URL', 'ultimate-member' ),
|
||||
'value' => ! empty( $role_data['_um_checkmail_url'] ) ? $role_data['_um_checkmail_url'] : '',
|
||||
'conditional' => array( '_um_checkmail_action', '=', 'redirect_url' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_login_email_activate',
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Login user after validating the activation link?', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Login the user after validating the activation link', 'ultimate-member' ),
|
||||
'value' => ! empty( $role_data['_um_login_email_activate'] ) ? $role_data['_um_login_email_activate'] : 0,
|
||||
'conditional' => array( '_um_status', '=', 'checkmail' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_url_email_activate',
|
||||
'type' => 'text',
|
||||
'label' => __( 'URL redirect after email activation', 'ultimate-member' ),
|
||||
'tooltip' => __( 'If you want users to go to a specific page other than login page after email activation, enter the URL here.', 'ultimate-member' ),
|
||||
'value' => ! empty( $role_data['_um_url_email_activate'] ) ? $role_data['_um_url_email_activate'] : '',
|
||||
'conditional' => array( '_um_status', '=', 'checkmail' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_pending_action',
|
||||
'type' => 'select',
|
||||
'label' => __( 'Action to be taken after registration', 'ultimate-member' ),
|
||||
'tooltip' => __( 'Select what action is taken after a person registers on your site. Depending on the status you can redirect them to their profile, a custom url or show a custom message', 'ultimate-member' ),
|
||||
'value' => ! empty( $role_data['_um_pending_action'] ) ? $role_data['_um_pending_action'] : array(),
|
||||
'options' => array(
|
||||
'show_message' => __( 'Show custom message', 'ultimate-member' ),
|
||||
'redirect_url' => __( 'Redirect to URL', 'ultimate-member' ),
|
||||
),
|
||||
'conditional' => array( '_um_status', '=', 'pending' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_pending_message',
|
||||
'type' => 'textarea',
|
||||
'label' => __( 'Personalize the custom message', 'ultimate-member' ),
|
||||
'value' => ! empty( $role_data['_um_pending_message'] ) ? $role_data['_um_pending_message'] : __( 'Thank you for applying for membership to our site. We will review your details and send you an email letting you know whether your application has been successful or not.', 'ultimate-member' ),
|
||||
'conditional' => array( '_um_pending_action', '=', 'show_message' ),
|
||||
),
|
||||
array(
|
||||
'id' => '_um_pending_url',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Set Custom Redirect URL', 'ultimate-member' ),
|
||||
'conditional' => array( '_um_pending_action', '=', 'redirect_url' ),
|
||||
'value' => ! empty( $role_data['_um_pending_url'] ) ? $role_data['_um_pending_url'] : '',
|
||||
),
|
||||
'conditional' => array( '_um_status', '=', 'pending' )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_pending_message',
|
||||
'type' => 'textarea',
|
||||
'label' => __( 'Personalize the custom message', 'ultimate-member' ),
|
||||
'value' => ! empty( $role['_um_pending_message'] ) ? __( $role['_um_pending_message'], 'ultimate-member' ) : __('Thank you for applying for membership to our site. We will review your details and send you an email letting you know whether your application has been successful or not.','ultimate-member'),
|
||||
'conditional' => array( '_um_pending_action', '=', 'show_message' )
|
||||
),
|
||||
array(
|
||||
'id' => '_um_pending_url',
|
||||
'type' => 'text',
|
||||
'label' => __( 'Set Custom Redirect URL', 'ultimate-member' ),
|
||||
'conditional' => array( '_um_pending_action', '=', 'redirect_url' ),
|
||||
'value' => ! empty( $role['_um_pending_url'] ) ? __( $role['_um_pending_url'], 'ultimate-member' ) : '',
|
||||
),
|
||||
)
|
||||
) )->render_form(); ?>
|
||||
|
||||
)->render_form();
|
||||
?>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user