Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-05-2009, 10:38 PM
Sprite- Sprite- is offline
 
Join Date: Dec 2007
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to fetch a userid

I am writing a script that uses vbulletin for usernames and userids.

Currently, I know I can use

$info = fetch_userinfo($userid);
$username=$info["username"];
echo $username;

to display a username for a userid.

My problem is going the other way around. Does anyone know how to display a userid for a username?

Any help would be appreciated. Thanks!

Edit: Also I am aware that I can do this with an sql query. I don't want to have to do that.
Reply With Quote
  #2  
Old 10-05-2009, 11:56 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Look up fetch_userid_from_username in the API
Reply With Quote
  #3  
Old 10-11-2009, 10:52 AM
Bandit8007 Bandit8007 is offline
 
Join Date: Jan 2006
Posts: 45
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

hello people can somebody help out on a lillte issue i have?

im using a own build php script that does read a txt file and tranfers it intoo a sorted php file
but it was build for a blog....

to tell what it does in short is....

ya can manually add releases to page... sofar it works fine but i can't get the userinfo on it

Code:
				global $user_identity;
				get_currentuserinfo();

				
				$todaydate = date("m/d/Y");
				
				$riplist .= '{[1] = [[music]],[2] = [['.$user_identity.']],[3] = [['.$todaydate.']],[4] = [['.$artist.' ('.$year.') '.$album.']],},'."\r\n";
			
			}
			
			// append closing bracket to riplist.
			$riplist = $riplist."}";
			
			// we have our riplist, now write to file.
			if ($handle = fopen ($rel_file3, "ab")) {
				// find the file size in bytes and remove one ie trailing bracket on last line
				$truncate = filesize("$rel_file3") - 1;
				// remove trailing bracket.
				ftruncate ($handle, $truncate);
				// write our new rips plus closing bracket }
				if (fwrite($handle, $riplist)) {
					print "<p>Thanks! Your rips were successfully added to the database.</p>";
				} else {
					print "<p>Something went wrong with the writing to DB file process. Please report to admin.</p>";
				}
				fclose($handle);
			} else {
				print "<p>Couldn't open the file for writing!</p>";
			}
		
		} else 
		
			print "<p>You didn't not add owt.</p>";
	
	}
sofar that works fine
but i have trouble to add the user that posted it

Code:
 				global $user_identity;
				get_currentuserinfo();

				
				$todaydate = date("m/d/Y");
				
				$riplist .= '{[1] = [[music]],[2] = [['.$user_identity.']],[3] = [['.$todaydate.']],[4] = [['.$artist.' ('.$year.') '.$album.']],},'."\r\n";
			
			}
the last coded part us the issue

cause im getting the error:

Fatal error: Call to undefined function fetch_userinfo() in /var/www/Forum/database/releases.php on line 324

line 324 is empty

322> global $user_identity;
323> get_currentuserinfo();
324> empty

any idea how to fix?
thnx
Reply With Quote
  #4  
Old 10-11-2009, 03:58 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This error:
PHP Code:
Call to undefined function fetch_userinfo() in /var/www/Forum/database/releases.php on line 324 
.... it can't find the function. Did you include the file that defines the function fetch_userinfo in your code?
Reply With Quote
  #5  
Old 10-11-2009, 05:53 PM
Bandit8007 Bandit8007 is offline
 
Join Date: Jan 2006
Posts: 45
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

im sorry i mixed up the first soultion... that was posted in here

the fatal error that takes place is
Code:
Fatal error: Call to undefined function get_currentuserinfo() in /var/www/Forum/database/releases.php on line 323
and this is what script does use now ( but thats wordpress code)
Code:
322> global $user_identity;
323> get_currentuserinfo();
324> empty
so it wont work with vbulletin

so im trying to get a work around to get the userinfo....
Reply With Quote
  #6  
Old 10-11-2009, 06:40 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Weel again, it's an unidentified function which means you are calling it, but the file that contains the function is not being included. What file do you identify the function get_currentuserinfo in?
Reply With Quote
  #7  
Old 10-12-2009, 02:23 PM
Bandit8007 Bandit8007 is offline
 
Join Date: Jan 2006
Posts: 45
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

well im not sure i understand fully...

but it does concern the current user thats on that(Vbulletin) page to post a release

to explain in short...

ive created a empty page as did get posted in here in mods
and used $include php for it

a part of that script is posted on post nr 9 above
anything does work fine on a wordpress instalation

but not on VB...

cause the member thats online on VB and that wants to post a release will not be added due that error it does gave...

so i need to change that script so it gets the user thats on VB and that does post that release....

maybe this helps you... ( i hope)..
if not then ill gave the full script ect what belongs to it... send me then a pm pls

gracias Lynne
Reply With Quote
  #8  
Old 10-12-2009, 02:46 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The problem is it wants to use the function get_currentuserinfo() but it is unable to since you haven't included the function in the script. Find the function in your files and either copy it into your page or include the page in your script:
PHP Code:
require_once(DIR '/thatPage.php'); 
Reply With Quote
  #9  
Old 10-13-2009, 05:26 AM
Bandit8007 Bandit8007 is offline
 
Join Date: Jan 2006
Posts: 45
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lynne i think ya total misunderstand me a bit or i fail to explain it correctly...
but im gonnay try to explaim a bit easyer

in root >> new made empty page called releases.php if has indeed included the php that needs to be show >>
PHP Code:
<tbody>
<tr>


<td colspan="2"><p><?php      include('database/releases.php'); ?></p>

    </tr>
</tbody>
</table>
that /database/releases.php <<<

does look for that userinfo

ill post that part ofl script

from line 322 until 354

and the error i do get comes from that line 324
(again this worked in wordpress but not in vbulletin)
Code:
				global $user_identity;
				get_currentuserinfo();

				
				$todaydate = date("m/d/Y");
				
				$riplist .= '{[1] = [[music]],[2] = [['.$user_identity.']],[3] = [['.$todaydate.']],[4] = [['.$artist.' ('.$year.') '.$album.']],},'."\r\n";
			
			}
			
			// append closing bracket to riplist.
			$riplist = $riplist."}";
			
			// we have our riplist, now write to file.
			if ($handle = fopen ($rel_file3, "ab")) {
				// find the file size in bytes and remove one ie trailing bracket on last line
				$truncate = filesize("$rel_file3") - 1;
				// remove trailing bracket.
				ftruncate ($handle, $truncate);
				// write our new rips plus closing bracket }
				if (fwrite($handle, $riplist)) {
					print "<p>Thanks! Your rips were successfully added to the database.</p>";
				} else {
					print "<p>Something went wrong with the writing to DB file process. Please report to admin.</p>";
				}
				fclose($handle);
			} else {
				print "<p>Couldn't open the file for writing!</p>";
			}
		
		} else 
		
			print "<p>You didn't not add owt.</p>";
	
	}
Reply With Quote
  #10  
Old 10-13-2009, 02:33 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, let's start with this.... what file is the function get_currentuserinfo in? Is it in the releases.php file? Is that file readable to the public? Try copying the function out of the file and putting it into your page - does it work now?
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 12:49 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.11070 seconds
  • Memory Usage 2,265KB
  • Queries Executed 11 (?)
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
  • (5)bbcode_code
  • (3)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
  • (2)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
  • (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_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete