Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-17-2012, 05:04 AM
Gabe505 Gabe505 is offline
 
Join Date: Feb 2004
Location: Albuquerque NM
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How Do You Add user Avatar image on homepage WGO box

I've done several searches and cannot find a solution. I'm Running vb4.1.0 Forum only.

Here is an example of what I'm trying to accomplish.
Attached Images
File Type: jpg screener-1.jpg (51.2 KB, 0 views)
Reply With Quote
  #2  
Old 07-19-2012, 03:37 AM
Gabe505 Gabe505 is offline
 
Join Date: Feb 2004
Location: Albuquerque NM
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Any takers?
Reply With Quote
  #3  
Old 07-19-2012, 03:58 AM
Sarteck's Avatar
Sarteck Sarteck is offline
 
Join Date: Mar 2008
Posts: 304
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sure, I'll bite.

AdminCP -> Products & Plugins -> Add New Plugin

Leave the Product as vBulletin (unless you wanted to make this a product, heh).

Select forumhome_loggedinuser for the Hook Location.

For the name, put something like "The Amazingly Awesome Sarteck's WGO-Avatar Plugin" or whatever.


For the PHP code, try the following:
PHP Code:
$loggedin['musername'] = '<img src="image.php?u='.$loggedin['userid'].'&type=thumb" />'
The size of the images is controlled by the size of the thumbs for avatars on your site.



Badabing, that's it.

--------------- Added [DATE]1342674039[/DATE] at [TIME]1342674039[/TIME] ---------------

-----------------
Actually, scratch that... Avatar thumbs would get cached like that. If you don't mind the caching, leave it as is. If you want to make sure the new image is displayed whenever someone changes their avatar, use this instead:

PHP Code:
$loggedin['musername'] = '<img src="image.php?u='.$loggedin['userid'].'&type=thumb&dateline='.TIMENOW.'" />'
--------------- Added [DATE]1342674110[/DATE] at [TIME]1342674110[/TIME] ---------------

Awesome username, btw.

--------------- Added [DATE]1342675184[/DATE] at [TIME]1342675184[/TIME] ---------------

Anudder update to that code for ya. If you wanted to force a certain size, add style="max-width:40px;max-height:40px;" to the image tag.

Change "40px" to whatever size you want.
Reply With Quote
  #4  
Old 07-20-2012, 02:56 AM
Gabe505 Gabe505 is offline
 
Join Date: Feb 2004
Location: Albuquerque NM
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I would love to change my username if possible (I've asked in the past but no dice). I will try this amazingly awesome plugin and update with my results. Thank you Sarteck YOU ROCK!

--------------- Added [DATE]1342758879[/DATE] at [TIME]1342758879[/TIME] ---------------

It works! But, is there a way to only display users with avatars or skip users without a avatar?
Reply With Quote
  #5  
Old 07-20-2012, 03:45 AM
Sarteck's Avatar
Sarteck Sarteck is offline
 
Join Date: Mar 2008
Posts: 304
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmmm. I am sure there is, but I don't know it right at the moment. I'll have to look into it some, unless someone else can give ya the answer before me.

--------------- Added [DATE]1342760313[/DATE] at [TIME]1342760313[/TIME] ---------------

Okay, we need to make another plugin on forumhome_loggedinuser_query.

This one needs to have the following:

PHP Code:
$hook_query_fields .= ", avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar ";
$hook_query_joins .= " LEFT JOIN " TABLE_PREFIX "avatar AS avatar ON (avatar.avatarid = user.avatarid) LEFT JOIN " TABLE_PREFIX "customavatar AS customavatar ON (customavatar.userid = user.userid) "
What this does is adds to the database query that looks up online users.



Now, we edit the old plugin we made earlier to use THIS PHP instead:
PHP Code:
if ($loggedin['avatarpath'] || $loggedin['hascustomavatar']) {$loggedin['musername'] = 'Whatever you decided for the Image HTML Tag.';} 
(Change as appropriate.)

What THAT one does is checks to see if the user has an avatar (a pre-set one from whatever you provide them as an Admin OR a custom one).

That -should- do it... But if you suddenly get Database Errors when you enable this, just kill that plugin what adds to the database lookup, because it means I mistyped soemthing. XP
Reply With Quote
  #6  
Old 07-20-2012, 03:59 AM
Gabe505 Gabe505 is offline
 
Join Date: Feb 2004
Location: Albuquerque NM
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I made the changes you provided above (also couldnt force the width and height). I added another screen shot to help explain.
Attached Images
File Type: jpg screener-3.jpg (21.1 KB, 0 views)
Reply With Quote
  #7  
Old 07-20-2012, 04:11 AM
Sarteck's Avatar
Sarteck Sarteck is offline
 
Join Date: Mar 2008
Posts: 304
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yup, I get ya. XD Replied above with a solution.

BTW, if you do not want names to display for those without avatars, but instead a default image that you can choose, try this in the plugin instead:

PHP Code:
if ($loggedin['avatarpath'] || $loggedin['hascustomavatar']) {$loggedin['musername'] = 'Whatever you decided for the Image HTML Tag.';} else {$loggedin['musername'] = '<img src="/path/to/your/image" />';} 
(Again, edit as necessary.)
Reply With Quote
  #8  
Old 07-20-2012, 04:51 AM
Gabe505 Gabe505 is offline
 
Join Date: Feb 2004
Location: Albuquerque NM
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the help and effort. It's working for me now, thank you! I just need to figure a few things out before I get it looking the way I want.

Example: Nothing displays for Invisible users and I would like to learn how to remove the "*" & "," from here.




BTW When searching for this solution I ran into quite a few other people asking how to do this. I'm sure this thread will become useful to others.
Reply With Quote
  #9  
Old 07-20-2012, 04:57 AM
Sarteck's Avatar
Sarteck Sarteck is offline
 
Join Date: Mar 2008
Posts: 304
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

UPDATE:

Two plugins.

Name: Avatar --> WGO [Database Query]
Location: forumhome_loggedinuser_query
PHP Code:
$hook_query_fields .= ", avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar ";
$hook_query_joins .= " LEFT JOIN " TABLE_PREFIX "avatar AS avatar ON (avatar.avatarid = user.avatarid) LEFT JOIN " TABLE_PREFIX "customavatar AS customavatar ON (customavatar.userid = user.userid) "

Name: Avatar --> WGO [Display]
Location: forumhome_loggedinuser
PHP Code:
$display_name_if_no_avatar true// Change to false if you do NOT want names appearing
$display_default_image ''// Change to the path to an image if you want to use a default image (takes precedence over $display_name_if_no_avatar)
$max_height '40px'// Change if you want.
$max_width '40px'// Change if you want.
$stylebit 'max-width:'.$max_width.';max-height:'.$max_height.';';
if (
$loggedin['avatarpath'] || $loggedin['hascustomavatar']) {$loggedin['musername'] = '<img src="image.php?u=' $loggedin['userid'] . '&type=thumb&dateline=' TIMENOW '" style="'.$stylebit.'" />';} // Displays user avatar thumbnail
elseif ($display_default_image) {$loggedin['musername'] = '<img src="$display_default_image" style="'.$stylebit.'" />';} // Displays default image
elseif (!$display_name_if_no_avatar) {continue;} // Continues the current loop without processing the username. 

Check out the comments so you know what to change.












EDIT: Posted this before I saw your response. I'll check that out in a minute.

EDIT2: Ah, the new stuff I put here already solves that, I think.
Reply With Quote
  #10  
Old 07-20-2012, 05:12 AM
Gabe505 Gabe505 is offline
 
Join Date: Feb 2004
Location: Albuquerque NM
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Database error in vBulletin 4.1.10:

Invalid SQL:

SELECT
user.username, (user.options & 512) AS invisible, user.usergroupid, user.lastvisit,
session.userid, session.inforum, session.lastactivity, session.badlocation,
IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid
, avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar , avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar
FROM session AS session
LEFT JOIN user AS user ON(user.userid = session.userid)
LEFT JOIN avatar AS avatar ON (avatar.avatarid = user.avatarid) LEFT JOIN customavatar AS customavatar ON (customavatar.userid = user.userid) LEFT JOIN avatar AS avatar ON (avatar.avatarid = user.avatarid) LEFT JOIN customavatar AS customavatar ON (customavatar.userid = user.userid)
WHERE session.lastactivity > 1342763809

ORDER BY username ASC;

MySQL Error : Not unique table/alias: 'avatar'
Error Number : 1066
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:35 PM.


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.04468 seconds
  • Memory Usage 2,305KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (7)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (2)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete