PluginProbe
MxChat – AI Chatbot & Content Generation for WordPress / 3.2.6
MxChat – AI Chatbot & Content Generation for WordPress v3.2.6
3.2.21 3.2.20 3.2.19 3.2.18 3.2.17 3.2.16 3.2.15 3.2.14 3.2.12 3.2.13 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 3.2.6 3.2.5 3.2.4 3.2.3 3.2.2 3.2.1 2.0.3 2.0.4 2.0.5 2.0.6 All 152 releases
mxchat-basic / includes / class-mxchat-user.php

class-mxchat-user.php in MxChat – AI Chatbot & Content Generation for WordPress 3.2.6, at includes/class-mxchat-user.php

30 lines 983 B
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 class MxChat_User {
7
8 // Function to get user identifier (username, email, or session ID)
9 public static function mxchat_get_user_identifier() {
10 if (is_user_logged_in()) {
11 $current_user = wp_get_current_user();
12 //error_log('Current User: ' . print_r($current_user, true));
13 return $current_user->user_login; // Use username as identifier
14 } else {
15 //error_log('User is not logged in. Using IP as identifier.');
16 return sanitize_text_field($_SERVER['REMOTE_ADDR']); // Use IP address as fallback
17 }
18 }
19
20 // Function to get user email
21 public static function mxchat_get_user_email() {
22 if (is_user_logged_in()) {
23 $current_user = wp_get_current_user();
24 return $current_user->user_email;
25 }
26 return null; // No email if not logged in
27 }
28 }
29
30