authentication - SugarCRM, Getting Current Logged in User Details through AJAX Call -
I have written a custom PHP file, which will be called by the AJAX request for SugarCRM. However, when I try to print
global $ current_user; Print_r ($ current_user); This prints an empty value with all the fields listed in the array below. User object ([name] = & gt; [full_name] = & gt [date] => [user_name] => [user_hash] => [salutary] = & Gt; [first_name] = & gt; [last_name] = & gt; [date_entered] => [date_modified] => [[Phone_mobile] => [phone_work] => [phone_thation] = & Gt; [created_by] = & gt; [built_by_name] = & gt; [modified_by_name] => [description] => [phone_home] => = & gt; [phone_fax] = & gt; [Email2] = & gt; [address_street] => [address_city] = & gt; [address_state] => [address_postalcode] => [address_country] = & gt [condition] => [ Title] = & gt; [portal_only] = & gt; 0 [section] = & gt; [authenticated] => [error_string] => [is_admin] => 0 [employee_status] => [Messenger_id] = & Gt; [Messenger_type] = & gt; [is_group] = & gt; [accept_status] => [team_id] => [receive_notifications] => 1 [default_team] => [reports_to_name] = & Gt; [reports_to_iD] = & gt; [team_exists] => [table_name] = & gt; User [module_rd] = & gt; User [item_name] = & gt; User [user_preferences] = & gt; [Importable] = & gt; 1
.....
I have searched the SugarCRM forum but no use. I suspect that the valid entry point may not be defined in my custom page, because it does not understand how to define except the following methods
If defined ('defined' )) Defined ('Chinese antire', true); If (defined! ('Sugar') || sugar entry) ('not a valid entry point'); Require_once ('include / entryPoint.php');
I know that this question is like 2013, the idea of sharing :)
This is when you call
global $ current_user; Outside of GQK, one option I have made, has created a hook in the custom user module and uses the $ current_user variable and only brings those essential values, probably saved on one session? Depending on you. Hope it helps someone :)
What did I do Create a file < Strong> custom_external_session.php
& lt ;? Php if (defined by ('sugar antiree') || sugar entry) die ('not a valid entry point'); Square custom_external_session {function get_current_user (and $ Focus, $ Event, $ argument) {global $ current_user; $ User_id = $ current_user-> Id; Session_start (); $ _SESSION ["custom_current_user"] = $ user_id; /} / Note: / var / www / html / sugarcrm / - - & gt; It depends on the place where you enter the word -
Then on that folder (/ custom / modules / users /) Then add logic_hooks.php to this code $ hook_array ['after_login'] [] = array (5, 'custom_external_session', 'custom / module / user / custom_exan_session.fp', 'Custom_external_session', 'get_current_user'); -
You can now use it: To get the current user_id, record $ _ session ["custom_conder_use"] , then you can play with it, You can edit or add more information in the saved session, say that you want fullname, just do it under custom_external_session; I'm not sure that there is a better way of working with external code -
When you edit custom_external_session, we Sha RELOGIN Remember, the value will I hope it is very clear to you.
Comments
Post a Comment