vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Get user via the API (https://vborg.vbsupport.ru/showthread.php?t=212460)

nickh 04-29-2009 07:52 PM

Get user via the API
 
Hi folks. Is there a way to use the vBulletin API to find a user based on their username, or must I search the "users" database table? If there is, would you mind pointing me at some docs, or including a code snippit?

Thanks,
Nick

Lynne 04-29-2009 08:30 PM

Did you look at the API - http://members.vbulletin.com/api/ ? There is a function called fetch_userid_from_username listed on there.

EnIgMa1234 04-29-2009 08:38 PM

You can use the function above in conjunction with fetch_userinfo get the the full info

nickh 04-30-2009 03:05 AM

Ack, I worded my question incorrectly.

I did indeed see fetch_userid_from_username() and fetch_userinfo(). However, those can only be used to get a user's info. Once you have that info, it's not possible to update it. Correct?

Using the vB API, is it possible to get a "user object", through which the user's data can be updated? For example:

PHP Code:

$user some_fetch_function($a_user_name);
$user->password 'something new';
$user->save(); 

Thanks,
Nick

Dismounted 04-30-2009 07:08 AM

You can pass it onto the user data manager. (See the manual about data managers.)

nickh 04-30-2009 03:28 PM

Quote:

Originally Posted by Lynne (Post 1801376)
Did you look at the API - http://members.vbulletin.com/api/ ? There is a function called fetch_userid_from_username listed on there.

Quote:

Originally Posted by EnIgMa1234 (Post 1801382)
You can use the function above in conjunction with fetch_userinfo get the the full info

Actually, I don't think this is possible. fetch_userid_from_username() is in admincp/usergroup.php , which isn't meant to be loaded using require() .

Other than querying the users database table, is there any other way to get a user's ID via their username?

Thanks,
Nick

Lynne 04-30-2009 03:36 PM

fetch_userinfo is in functions.php.

You can always copy functions to your plugins if you need them.

nickh 04-30-2009 03:42 PM

Right, but fetch_userinfo() is only useful if one has the user's ID.

For many reasons, copying functions is not a good idea. Doing so violates the DRY principle, makes your code brittle with respect to vBulletin updates, etc. Also, it negates the whole point of having an API.

Lynne 04-30-2009 03:52 PM

Then all I can suggest is a quick query. I know that's what I do in some of my customized site code.

nickh 04-30-2009 04:56 PM

Thanks for your insight, Lynne. It's helpful to hear what others have done in the past.


All times are GMT. The time now is 07:24 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.01017 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
  • (10)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