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

XF 1.1 custom avatar management

Discussion in 'XenForo Questions and Support' started by ghiboz, Nov 4, 2012.

  1. ghiboz

    ghiboz Member

    hi all!
    I have this thing to do:
    I wish that the avatar of my forum users was not availabe to modifying and point to a specific url like this:
    http://myWebsite.com/avatars.php?uid=123 where uid is the user id from the forum..

    how can I do this?
    thanks in advance!
  2. Chris D

    Chris D XenForo Developer Staff Member

    Jake Bunce likes this.
  3. ghiboz

    ghiboz Member

    thanks Chris, but I need exactly the inverse thing: I wish that the user must not be able to select a personal avatar, 'cause is took by default from an url as shown above;
    for simply the thing: suppose that you have a folder into a website with a .png file with the name equal to the id: for example in this forum: mine will be 3220.png, your 11388.png, and the avatar is exactly it ;)
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    All avatars on the forum call on this function:


    You could modify that function to suit your needs.

    edit - in this file:

    feldon30 likes this.
  5. ghiboz

    ghiboz Member

    thanks Jake, so I need to modify brutally a file, no chance to build some plugin or similar ;)
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Yes you can put the code changes into a plugin. It still requires custom programming.
  7. ghiboz

    ghiboz Member

    thanks, and where I can understand how to do this?
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  9. ghiboz

    ghiboz Member

    thanks... I'm a programmer, I know php, but the add-ons structure is dark for my mind
  10. feldon30

    feldon30 Well-Known Member

    Yeah I am trying to modify /library/XenForo/Template/Helper/Core.php to allow remotely-linked avatars. And before someone says "Why would you ever need remotely linked avatars?" I am dealing with a corporate client who does not want to allow uploads PERIOD.

    I created a Custom User Profile Field named 'avatarurl'. That was the easy part.

    So I tried to code the "right" way and use the helper function helperUserFieldValue() but after 1 hour of trying cannot get any variation on this to work:

    $avatarurl = call_user_func(self::$helperCallbacks['userfieldvalue'], 'avatarurl', $user);

    So then I resorted to $user['customFields']['avatarurl']. This works great, except for those few places where $user['customFields'] is not set and the best you can hope for is $user['custom_fields'] which is serialized data. I'd rather not have to try to unpack and parse a serialized string if I can help it.

    P.S. I wouldn't know where to begin writing this as a Plugin. I figure I'll be lucky just to get this working as a code hack. :(

Share This Page