vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Best way to obtain username from userid (https://vborg.vbsupport.ru/showthread.php?t=221613)

mangus580 08-24-2009 02:52 AM

Best way to obtain username from userid
 
What is the best method of getting a username when you have the userid?

I am working on a watermark plugin, that uses the hook attachment_display. It seems I can come up with the userid that posted the attachment quite easily, but I am unable to easily turn that into a username which is what I ultimately want.

Can anyone suggest anything?

Thanks!

Lynne 08-24-2009 04:00 AM

If this is a continuation of your attachment mod from another thread, it might have been smart to keep this question in there so users have all the information. In this particular case, you should just JOIN the user table in the attachment query to grab the username at the same time all the other info about the user is grabbed. It looks like the hook to use would be attachment_start. It's always best to take a look at the code around any hook you are using (in this case the attachment_display hook) and see what else is going on (I said that before in regards to finding the userid).

mangus580 08-24-2009 03:28 PM

I started a new tread, as I felt it was a different topic really... sorry :-(

What you describe sounds like an edit to a core file, is this true? I am really trying to avoid that if possible....

James Birkett 08-24-2009 03:59 PM

Hooks are used to use custom code without having to edit source files.
Admin CP -> Plugins & Products -> Add New Plugin
Product: vBulletin
Hook: attachment_start
Title: Whatever you like
PHP Code: {Your code}
Plugin is Active: Yes

Lynne 08-24-2009 04:30 PM

Quote:

Originally Posted by mangus580 (Post 1873448)
What you describe sounds like an edit to a core file, is this true? I am really trying to avoid that if possible....

Nope, just a plugin as James describes below:

Quote:

Originally Posted by James Birkett (Post 1873482)
Hooks are used to use custom code without having to edit source files.
Admin CP -> Plugins & Products -> Add New Plugin
Product: vBulletin
Hook: attachment_start
Title: Whatever you like
PHP Code: {Your code}
Plugin is Active: Yes

PHP Code:

$hook_query_fields ",user.username ";
$hook_query_joins join the user table here 


mangus580 08-24-2009 10:55 PM

Got it, THANKS!!


All times are GMT. The time now is 10:27 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.02615 seconds
  • Memory Usage 1,731KB
  • 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
  • (1)bbcode_php_printable
  • (2)bbcode_quote_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