| Server IP : 13.126.101.145 / Your IP : 216.73.217.50 Web Server : Apache/2.4.52 (Ubuntu) System : Linux ip-11-115-0-196 6.8.0-1039-aws #41~22.04.1-Ubuntu SMP Thu Sep 11 10:54:48 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 8.3.17 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/rentals_updated/wp-content/plugins/wpo365-login/Graph/ |
Upload File : |
<?php
namespace Wpo\Graph;
// Prevent public access to this script
defined('ABSPATH') or die();
use \Wpo\Services\Log_Service;
use \Wpo\Services\Options_Service;
if (!class_exists('\Wpo\Graph\Current_User')) {
class Current_User
{
/**
* Returns basic information for the current user incl. the user's (Azure AD) UPN and Object ID.
*
* @since 13.0
*
* @return array The user's login, email, display name, ID, UPN and AAD Object ID.
*/
public static function get_current_user()
{
Log_Service::write_log('DEBUG', '##### -> ' . __METHOD__);
$wp_usr_id = \get_current_user_id();
$user_info = \wp_get_current_user();
$user_login = !empty($user_info->user_login) ? $user_info->user_login : '';
$user_email = !empty($user_info->user_email) ? $user_info->user_email : '';
$display_name = !empty($user_info->display_name) ? $user_info->display_name : '';
$id = $user_info->ID;
$upn = \get_user_meta($wp_usr_id, 'userPrincipalName', true);
$aad_object_id = \get_user_meta($wp_usr_id, 'aadObjectId', true);
return array(
"user_login" => $user_login,
"user_email" => $user_email,
"display_name" => $display_name,
"id" => $id,
"upn" => !empty($upn) ? $upn : '',
"aad_object_id" => !empty($aad_object_id) ? $aad_object_id : '',
);
}
}
}