mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-11 18:56:10 +09:00
- changed wp-admin > Users page;
* updated filters by status, avoid slow queries for getting users count; * updated bulk-actions for changing statuses (moved to WP native dropdown) * separate handlers for changing user statuses on wp-admin and frontend (partially implemented); * created class UM()->common()->users() to handle user statuses in more clear format; * deprecated old hooks and old functions
This commit is contained in:
+35
-304
@@ -130,7 +130,6 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
add_action( 'personal_options_update', array( &$this, 'remove_cache' ) );
|
||||
//add_action('edit_user_profile_update', array(&$this, 'remove_cache') );
|
||||
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, 'profile_form_additional_section' ), 10 );
|
||||
add_action( 'user_new_form', array( $this, 'profile_form_additional_section' ), 10 );
|
||||
@@ -1504,134 +1503,23 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
/**
|
||||
* Set user's account status
|
||||
*
|
||||
* @param $status
|
||||
* @deprecated 2.8.7
|
||||
*
|
||||
* @param string $status
|
||||
*/
|
||||
function set_status( $status ) {
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_when_status_is_set
|
||||
* @description Action on user status changed
|
||||
* @input_vars
|
||||
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_when_status_is_set', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_when_status_is_set', 'my_when_status_is_set', 10, 1 );
|
||||
* function my_when_status_is_set( $user_id ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_when_status_is_set', um_user( 'ID' ) );
|
||||
|
||||
$this->profile['account_status'] = $status;
|
||||
|
||||
$this->update_usermeta_info( 'account_status' );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_after_user_status_is_changed_hook
|
||||
* @description Action after user status changed
|
||||
* @input_vars
|
||||
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_after_user_status_is_changed_hook', 'function_name', 10 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_after_user_status_is_changed_hook', 'my_after_user_status_is_changed', 10 );
|
||||
* function my_after_user_status_is_changed() {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_after_user_status_is_changed_hook', um_user( 'ID' ) );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_after_user_status_is_changed
|
||||
* @description Action after user status changed
|
||||
* @input_vars
|
||||
* [{"var":"$status","type":"string","desc":"User Status"},
|
||||
* {"var":"$user_id","type":"integer","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_after_user_status_is_changed', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_after_user_status_is_changed', 'my_after_user_status_is_changed', 10, 1 );
|
||||
* function my_after_user_status_is_changed( $status ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_after_user_status_is_changed', $status, um_user( 'ID' ) );
|
||||
|
||||
public function set_status( $status ) {
|
||||
_deprecated_function( __METHOD__, '2.8.7', 'UM()->common()->users()->set_status()' );
|
||||
UM()->common()->users()->set_status( $status, um_user( 'ID' ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set user's hash
|
||||
*/
|
||||
function assign_secretkey() {
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_before_user_hash_is_changed
|
||||
* @description Action before user hash is changed
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_before_user_hash_is_changed', 'function_name', 10 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_before_user_hash_is_changed', 'my_before_user_hash_is_changed', 10 );
|
||||
* function my_before_user_hash_is_changed() {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_before_user_hash_is_changed' );
|
||||
|
||||
$this->profile['account_secret_hash'] = UM()->validation()->generate();
|
||||
$this->update_usermeta_info( 'account_secret_hash' );
|
||||
|
||||
$expiry_time = UM()->options()->get( 'activation_link_expiry_time' );
|
||||
if ( ! empty( $expiry_time ) && is_numeric( $expiry_time ) ) {
|
||||
$this->profile['account_secret_hash_expiry'] = time() + $expiry_time * DAY_IN_SECONDS;
|
||||
$this->update_usermeta_info( 'account_secret_hash_expiry' );
|
||||
}
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_after_user_hash_is_changed
|
||||
* @description Action after user hash is changed
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_after_user_hash_is_changed', 'function_name', 10 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_after_user_hash_is_changed', 'my_after_user_hash_is_changed', 10 );
|
||||
* function my_after_user_hash_is_changed() {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_after_user_hash_is_changed' );
|
||||
public function assign_secretkey() {
|
||||
_deprecated_function( __METHOD__, '2.8.7', 'UM()->common()->users()->assign_secretkey()' );
|
||||
UM()->common()->users()->assign_secretkey( um_user( 'ID' ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param \WP_User $userdata
|
||||
*
|
||||
@@ -1677,186 +1565,53 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
|
||||
/**
|
||||
* This method approves a user membership and sends them an optional welcome/approval email.
|
||||
*
|
||||
* @usage <?php UM()->user()->approve(); ?>
|
||||
*
|
||||
* @example Approve a pending user and allow him to sign-in to your site.
|
||||
|
||||
<?php
|
||||
|
||||
um_fetch_user( 352 );
|
||||
UM()->user()->approve();
|
||||
|
||||
?>
|
||||
*
|
||||
* @param bool $repeat @deprecated
|
||||
* @deprecated 2.8.7
|
||||
*/
|
||||
public function approve( $repeat = true ) {
|
||||
$user_id = um_user( 'ID' );
|
||||
|
||||
if ( ! $repeat ) {
|
||||
$status = get_user_meta( $user_id, 'account_status', true );
|
||||
if ( 'approved' === $status ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
delete_option( "um_cache_userdata_{$user_id}" );
|
||||
|
||||
if ( 'awaiting_admin_review' === um_user( 'account_status' ) ) {
|
||||
$userdata = get_userdata( $user_id );
|
||||
|
||||
$this->maybe_generate_password_reset_key( $userdata );
|
||||
|
||||
UM()->mail()->send( um_user( 'user_email' ), 'approved_email' );
|
||||
|
||||
} else {
|
||||
//$userdata = get_userdata( $user_id );
|
||||
//get_password_reset_key( $userdata );
|
||||
UM()->mail()->send( um_user( 'user_email' ), 'welcome_email' );
|
||||
}
|
||||
|
||||
$this->set_status( 'approved' );
|
||||
$this->delete_meta( 'account_secret_hash' );
|
||||
$this->delete_meta( 'account_secret_hash_expiry' );
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_after_user_is_approved
|
||||
* @description Action after user was approved
|
||||
* @input_vars
|
||||
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_after_user_is_approved', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_after_user_is_approved', 'my_after_user_is_approved', 10, 1 );
|
||||
* function my_after_user_hash_is_changed( $user_id ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_after_user_is_approved', um_user( 'ID' ) );
|
||||
public function approve( $repeat = true ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found -- deprecated function
|
||||
_deprecated_function( __METHOD__, '2.8.7', 'UM()->common()->users()->approve()' );
|
||||
UM()->common()->users()->approve( um_user( 'ID' ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pending email
|
||||
* @deprecated 2.8.7
|
||||
*/
|
||||
function email_pending() {
|
||||
$this->assign_secretkey();
|
||||
$this->set_status( 'awaiting_email_confirmation' );
|
||||
|
||||
//clear all sessions for email confirmation pending users
|
||||
$user = \WP_Session_Tokens::get_instance( um_user( 'ID' ) );
|
||||
$user->destroy_all();
|
||||
|
||||
UM()->mail()->send( um_user( 'user_email' ), 'checkmail_email' );
|
||||
public function email_pending() {
|
||||
_deprecated_function( __METHOD__, '2.8.7', 'UM()->common()->users()->send_activation()' );
|
||||
UM()->common()->users()->send_activation( um_user( 'ID' ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method puts a user under manual review by administrator and sends them an optional email.
|
||||
*
|
||||
* @usage <?php UM()->user()->pending(); ?>
|
||||
*
|
||||
* @example An example of putting a user pending manual review
|
||||
|
||||
<?php
|
||||
|
||||
um_fetch_user( 54 );
|
||||
UM()->user()->pending();
|
||||
|
||||
?>
|
||||
*
|
||||
* @deprecated 2.8.7
|
||||
* @return void
|
||||
*/
|
||||
function pending() {
|
||||
$this->set_status( 'awaiting_admin_review' );
|
||||
|
||||
//clear all sessions for awaiting admin confirmation users
|
||||
$user = \WP_Session_Tokens::get_instance( um_user( 'ID' ) );
|
||||
$user->destroy_all();
|
||||
|
||||
UM()->mail()->send( um_user( 'user_email' ), 'pending_email' );
|
||||
public function pending() {
|
||||
_deprecated_function( __METHOD__, '2.8.7', 'UM()->common()->users()->set_as_pending()' );
|
||||
UM()->common()->users()->set_as_pending( um_user( 'ID' ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method rejects a user membership and sends them an optional email.
|
||||
*
|
||||
* @usage <?php UM()->user()->reject(); ?>
|
||||
*
|
||||
* @example Reject a user membership example
|
||||
|
||||
<?php
|
||||
|
||||
um_fetch_user( 114 );
|
||||
UM()->user()->reject();
|
||||
|
||||
?>
|
||||
|
||||
*
|
||||
* @deprecated 2.8.7
|
||||
* @return void
|
||||
*/
|
||||
function reject() {
|
||||
$this->set_status( 'rejected' );
|
||||
|
||||
//clear all sessions for rejected users
|
||||
$user = \WP_Session_Tokens::get_instance( um_user( 'ID' ) );
|
||||
$user->destroy_all();
|
||||
|
||||
UM()->mail()->send( um_user( 'user_email' ), 'rejected_email' );
|
||||
public function reject() {
|
||||
_deprecated_function( __METHOD__, '2.8.7', 'UM()->common()->users()->reject()' );
|
||||
UM()->common()->users()->reject( um_user( 'ID' ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method deactivates a user membership and sends them an optional email.
|
||||
*
|
||||
* @usage <?php UM()->user()->deactivate(); ?>
|
||||
*
|
||||
* @example Deactivate a user membership with the following example
|
||||
|
||||
<?php
|
||||
|
||||
um_fetch_user( 32 );
|
||||
$ultimatemember->user->deactivate();
|
||||
|
||||
?>
|
||||
*
|
||||
* @deprecated 2.8.7
|
||||
* @return void
|
||||
*/
|
||||
function deactivate() {
|
||||
$this->set_status( 'inactive' );
|
||||
|
||||
//clear all sessions for inactive users
|
||||
$user = \WP_Session_Tokens::get_instance( um_user( 'ID' ) );
|
||||
$user->destroy_all();
|
||||
|
||||
/**
|
||||
* UM hook
|
||||
*
|
||||
* @type action
|
||||
* @title um_after_user_is_inactive
|
||||
* @description Action after user was inactive
|
||||
* @input_vars
|
||||
* [{"var":"$user_id","type":"int","desc":"User ID"}]
|
||||
* @change_log
|
||||
* ["Since: 2.0"]
|
||||
* @usage add_action( 'um_after_user_is_inactive', 'function_name', 10, 1 );
|
||||
* @example
|
||||
* <?php
|
||||
* add_action( 'um_after_user_is_inactive', 'my_after_user_is_inactive', 10, 1 );
|
||||
* function my_after_user_is_inactive( $user_id ) {
|
||||
* // your code here
|
||||
* }
|
||||
* ?>
|
||||
*/
|
||||
do_action( 'um_after_user_is_inactive', um_user( 'ID' ) );
|
||||
|
||||
UM()->mail()->send( um_user( 'user_email' ), 'inactive_email' );
|
||||
public function deactivate() {
|
||||
_deprecated_function( __METHOD__, '2.8.7', 'UM()->common()->users()->deactivate()' );
|
||||
UM()->common()->users()->deactivate( um_user( 'ID' ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete user
|
||||
*
|
||||
@@ -2522,7 +2277,6 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
return $hash_email_address;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* UM Placeholders for activation link in email
|
||||
*
|
||||
@@ -2530,12 +2284,11 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function add_activation_placeholder( $placeholders ) {
|
||||
public function add_activation_placeholder( $placeholders ) {
|
||||
$placeholders[] = '{account_activation_link}';
|
||||
return $placeholders;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* UM Replace Placeholders for activation link in email
|
||||
*
|
||||
@@ -2543,31 +2296,9 @@ if ( ! class_exists( 'um\core\User' ) ) {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function add_activation_replace_placeholder( $replace_placeholders ) {
|
||||
public function add_activation_replace_placeholder( $replace_placeholders ) {
|
||||
$replace_placeholders[] = um_user( 'account_activation_link' );
|
||||
return $replace_placeholders;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get pending users (in queue)
|
||||
*
|
||||
* @deprecated 2.4.2
|
||||
*/
|
||||
function get_pending_users_count() {
|
||||
_deprecated_function( __METHOD__, '2.4.2', 'UM()->query()->get_pending_users_count()' );
|
||||
return UM()->query()->get_pending_users_count();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove cached queue from Users backend
|
||||
*
|
||||
* @deprecated 2.4.2
|
||||
*/
|
||||
function remove_cached_queue() {
|
||||
_deprecated_function( __METHOD__, '2.4.2', '' );
|
||||
delete_option( 'um_cached_users_queue' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user