1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Global Variable for IP Addresses?

Discussion in 'XenForo Questions and Support' started by James, Jan 22, 2011.

  1. James

    James Well-Known Member

    I'm not sure if I've missed it or if it doesn't exist, but I've been looking for a variable for the current user's IP address ($bbuserinfo equivalent for vBulletin (ex-)customers), and can't find it anywhere.

    Does anyone know if this exists and what it is?
  2. Mike

    Mike XenForo Developer Staff Member

    That's just in the server array ($_SERVER['REMOTE_ADDR']). It's not something we ever expose to the templates though.
  3. James

    James Well-Known Member

    So I should just call the variable via the standard $_SERVER['REMOTE_ADDR'] approach instead of a {$user.ip} approach?

    EDIT: Never mind, tried $_SERVER['REMOTE_ADDR'], {$ipInfo.confirmationIp}, {$ipInfo.registrationIp} and {$ipInfo.contentIp}.

    I'm going to try to {xen:set} an IP variable now... or is it possible to map the IP variable? I'll get to work on this tomorrow.
  4. Mike

    Mike XenForo Developer Staff Member

    You know, since it's a super global, I suppose {$_SERVER.REMOTE_ADDR} should work.
  5. James

    James Well-Known Member

    Ah, of course! The only reason it didn't work last time is because I temporarily forgot that arrays use the period instead of the usual [' '].

    Thanks Mike :)

Share This Page