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

XF 1.1 Show Age in message_user_info

Discussion in 'XenForo Questions and Support' started by Crazy-Achmet, May 30, 2012.

  1. Crazy-Achmet

    Crazy-Achmet Active Member


    just a quick question: Is it possible to show the age of a user in message_user_info template?

    Thanks in advance for your help! :)

  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Crazy-Achmet and Yorick like this.
  3. Chris D

    Chris D XenForo Developer Staff Member

    From the quick test I've just done, no.

    {xen:number $birthday.age} is what displays the age (if the date and year of birth has been provided) in the profile.

    That parameter then isn't passed to another template, so I would suspect that you'd need an add on for that to work.

    Don't worry about posting in the add-on request forum just yet. I might be able to work this out.

    EDIT: Ninjaaa!
    Crazy-Achmet likes this.
  4. James

    James Well-Known Member

    You can use XenForo_Model_UserProfile::calculateAge($year, $month, $day) to calculate their age, but that doesn't respect user privacy.

    Instead, you should use XenForo_Model_UserProfile::getUserAge(array $user, $force = false)
    (if force = true - ignore user privacy).

    From there, you just pass the information to the $viewParams in XenForo_ControllerPublic_Thread::actionIndex();

    Yorick likes this.
  5. Chris D

    Chris D XenForo Developer Staff Member

    Thanks for this, so useful.

    I had a go earlier but because I'm a beginner I got lost. I found getUserAge but was going about things in the wrong way.
  6. James

    James Well-Known Member

    Let me try a quick add-on for you to look at.
    Crazy-Achmet and Yorick like this.

Share This Page