Uname: Linux premium294.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
Software: LiteSpeed
PHP version: 8.1.32 [ PHP INFO ] PHP os: Linux
Server Ip: 104.21.48.1
Your Ip: 216.73.216.223
User: mjbynoyq (1574) | Group: mjbynoyq (1570)
Safe Mode: OFF
Disable Function:
NONE

name : class-users.php
<?php
namespace um\ajax;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class Users
 *
 * @package um\ajax
 */
class Users {

	public function __construct() {
		add_action( 'wp_ajax_um_get_users', array( $this, 'get_users' ) );
	}

	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,
			)
		);
	}
}
© 2025 XylotrechusZ