vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Getting user avatar URL? (https://vborg.vbsupport.ru/showthread.php?t=313333)

findingpeace 07-29-2014 04:43 PM

Getting user avatar URL?
 
I try to use the official avatarurl because it has the dateline built in (so stuff doesn't get stuck in cache when people update their avatar), but it's not in a lot of templates. So I've tried making a plugin to make it work manually, but I'm having some trouble.

Example with MEMBERINFO:

Code:

require_once('./includes/functions_user.php');
$avatarurl = fetch_avatar_url($vbulletin->userinfo['userid']);

vB_Template::preRegister('MEMBERINFO', array('avatarurl' => $avatarurl[0]));

Then in MEMBERINFO, I use:
Code:

{vb:raw avatarurl}
It sort of works, except it displays my OWN avatar everywhere! Basically it just seems to take the current user's avatar and display it.

What I need is for the user ID to match the user ID of the profile I'm viewing. So if I'm user 1, and I view user 5's profile, I should see user 5's avatar, not my own.

Thanks!

tbworld 07-29-2014 05:20 PM

What hook are you using for your plugin?

cellarius 07-29-2014 05:25 PM

$vbulletin->userinfo holds the userid of the user browsing the page (in this case: you). You need to get the id of the user who owns the profile. What variable to use depends on the hook you use.

findingpeace 07-29-2014 05:37 PM

I'm just using global_start so I can register the variable in multiple templates. Is this wrong? How would you recommend I do this just do display on MEMBERINFO, for example?

tbworld 07-29-2014 08:31 PM

The only problem you are having is your target. As @Cellarius stated the variable you are trying to use is incorrect.

The following will work in MEMBERINFO template, although I did not check the dateline param which I should have added -- if possible.
Code:

  <img src="{vb:raw vboptions.bburl}/image.php?{vb:raw session.sessionurl}u={vb:raw show_userid}" />
I did not have much time to look into this, a bit busy with life. Your code should have worked on hook "member_complete" with variable "$vbulletin->GPC['userid']", but for some reason it did not. I will take a look at it later.

--------------- Added 29 Jul 2014 at 22:04 ---------------

The hook code works fine. I had missed creating an actual avatar for the test user. :) That stuff happens when you are juggling too many things.


Code:

    //Hook: member_complete

    require_once('./includes/functions_user.php');
    $avatarurl = fetch_avatar_url($vbulletin->GPC['userid']);
    vB_Template::preRegister('MEMBERINFO', array('avatarurl' => $avatarurl));

:)

findingpeace 07-30-2014 11:34 AM

Thank you so much tbworld! I am out of "Likes" to give you :)


All times are GMT. The time now is 02:17 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01102 seconds
  • Memory Usage 1,718KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete