PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 2.3.1
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v2.3.1
3.5.4 3.5.3 3.5.2 3.5.1 3.4.9 3.5.0 3.4.8 3.4.7 trunk 2.3.1 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6
supportcandy / includes / admin / tickets / create_ticket / get_users.php

get_users.php in SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent 2.3.1, at includes/admin/tickets/create_ticket/get_users.php

55 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly
4 }
5
6 global $current_user, $wpdb;
7 if (!($current_user->ID && $current_user->has_cap('wpsc_agent'))) {exit;}
8
9 $term = isset($_REQUEST) && isset($_REQUEST['term']) ? sanitize_text_field($_REQUEST['term']) : '';
10 if (!$term) {exit;}
11
12 $output = array();
13
14 $args = array (
15 'meta_query' => array(
16 'relation' => 'OR',
17 array(
18 'key' => 'first_name',
19 'value' => $term,
20 'compare' => 'LIKE'
21 ),
22 array(
23 'key' => 'last_name',
24 'value' => $term,
25 'compare' => 'LIKE'
26 )
27 )
28 );
29 $wp_user_query = new WP_User_Query($args);
30 $usermeta = $wp_user_query->get_results();
31
32 $users = get_users(array('search'=>'*'.$term.'*','number' => 5));
33 $users_dup = array_merge($users,$usermeta);
34 $users = array_unique($users_dup, SORT_REGULAR);
35
36 foreach ($users as $user) {
37 $output[] = array(
38 'id' => $user->ID,
39 'label' => $user->display_name,
40 'value' => $user->display_name,
41 'email' => $user->user_email,
42 );
43 }
44
45 if (!$output) {
46 $output[] = array(
47 'id' => '',
48 'label' => __('No matching users','supportcandy'),
49 'value' => '',
50 'email' => '',
51 );
52 }
53
54 wp_send_json($output);
55