Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Get the ID of the current logged in user

  1. #1
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default Get the ID of the current logged in user

    Hi,

    How to I get information on the Current Logged in User, such as username, id, etc.

    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  2. #2
    AlexAv's Avatar
    AlexAv is offline Sugar Community Member
    Join Date
    Oct 2009
    Location
    Ukraine
    Posts
    922

    Default Re: Get the ID of the current logged in user

    Hello,

    You can use the code below.

    PHP Code:
    global $current_user;
    echo 
    $current_user->id;
    echo 
    $current_user->user_name
    Last edited by AlexAv; 2010-02-24 at 11:51 AM.
    Letrium ltd. - Only high quality service
    http://letrium.com

  3. #3
    jsagar's Avatar
    jsagar is offline Sugar Community Member
    Join Date
    Mar 2008
    Location
    Ahmedabad,India
    Posts
    242

    Default Re: Get the ID of the current logged in user

    hi,
    you can get by global variables
    global $current_user;
    Best Regards
    ---------------------------------------
    Jaydeepsinh Sagar

  4. #4
    jsagar's Avatar
    jsagar is offline Sugar Community Member
    Join Date
    Mar 2008
    Location
    Ahmedabad,India
    Posts
    242

    Default Re: Get the ID of the current logged in user

    hi.
    sorry i just submit reply(lately).
    it's duplicate the answer of AlexAv.
    Best Regards
    ---------------------------------------
    Jaydeepsinh Sagar

  5. #5
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default Re: Get the ID of the current logged in user

    Thanks thats perfect.

    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  6. #6
    limj1005 is offline Senior Member
    Join Date
    Mar 2010
    Posts
    20

    Default Re: Get the ID of the current logged in user

    i can get the id of current logged on just wif the code above?

    i tried but nth is displaying

  7. #7
    rishavraj's Avatar
    rishavraj is offline Sugar Community Member
    Join Date
    Sep 2010
    Posts
    135

    Default Re: Get the ID of the current logged in user

    How can i get the current user_id in java-script; i have write some java-script condition code lke

    if(document.getElementById('assigned_user_id').val ue == '{{$current_id}}') { }

    Here '{{$current_id}}') is not working

  8. #8
    AlexAv's Avatar
    AlexAv is offline Sugar Community Member
    Join Date
    Oct 2009
    Location
    Ukraine
    Posts
    922

    Default Re: Get the ID of the current logged in user

    Quote Originally Posted by rishavraj View Post
    How can i get the current user_id in java-script; i have write some java-script condition code lke

    if(document.getElementById('assigned_user_id').val ue == '{{$current_id}}') { }

    Here '{{$current_id}}') is not working
    What you need to do?
    Letrium ltd. - Only high quality service
    http://letrium.com

  9. #9
    rishavraj's Avatar
    rishavraj is offline Sugar Community Member
    Join Date
    Sep 2010
    Posts
    135

    Question Re: Get the ID of the current logged in user

    While assigning the accounts to other user it will alert the javascript message. if assignuser_id = curretnuser_if then return false else it will dispaly the alert message.

    I am writing logic_hook for this my javascript code as follows

    function check_save() {

    if(document.getElementById('assigned_user_id').val ue == '{{$current_id}}') {
    document.getElementById('warning').innerHTML = 'Error: Explanation of error';
    $j("#warning").fadeIn("slow");
    setTimeout('$j("#warning").fadeOut("slow");',20000 );
    return false;
    }else {
    return false;
    }
    }
    Here {{$current_id}} is not working

  10. #10
    AlexAv's Avatar
    AlexAv is offline Sugar Community Member
    Join Date
    Oct 2009
    Location
    Ukraine
    Posts
    922

    Default Re: Get the ID of the current logged in user

    Please show me all hook file code.
    Letrium ltd. - Only high quality service
    http://letrium.com

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Lead conversion causes user to logged out
    By Mithun in forum Developer Help
    Replies: 10
    Last Post: 2009-06-01, 11:53 AM
  2. How to get the user logged??
    By fedepia in forum Help
    Replies: 6
    Last Post: 2008-09-19, 03:58 PM
  3. User logged out after popup window displayed
    By kerryjohnreynolds in forum Help
    Replies: 1
    Last Post: 2006-05-06, 08:07 AM
  4. Replies: 3
    Last Post: 2006-04-24, 03:14 AM
  5. User logged out when IP dynamically changed
    By MMorgan in forum General Discussion
    Replies: 2
    Last Post: 2005-11-04, 06:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •