View Full Version : Custom Variable in Postbit
evenmonkeys
07-27-2012, 04:17 AM
I want to make a plugin, place a variable in it, and call it in "postbit_legacy". I can't figure out the plugin hook I use. I tried "postbit_display_start" but it didn't work. It actually broke my forum.
Any direction will be appreciated.
evenmonkeys
07-29-2012, 03:38 AM
Still trying to figure this out. -_-;
HMBeaty
07-29-2012, 03:41 AM
More information would be nice ;) For example.... what is the code you are trying to use? What do you mean it broke your forum? What exactly are you trying to do/accomplish?
evenmonkeys
07-29-2012, 04:45 AM
I made a table for a game on my forum. In that table is a score for each user. I want to display that score on the postbit. I can't figure it out.
Lynne
07-29-2012, 05:53 PM
So post the code you have written and let us see where you went wrong.
evenmonkeys
07-30-2012, 04:55 AM
Plugin: postbit_display_start
$gameuserid = $post['userid'];
$player_sql = $vbulletin->db->query("SELECT * FROM gametable WHERE userid = '$gameuserid'");
$player = $vbulletin->db->fetch_array($player_sql);
$player_score = $player['score'];
Template: postbit_legacy
Score: $player_score
Gives this error:
Fatal error: Call to a member function query() on a non-object in /forums/includes/class_postbit.php(265) : eval()'d code on line 86
Lynne
07-30-2012, 03:59 PM
I've always used postbit_display_complete for adding stuff to the postbit.
You may need to use $this->post instead of $post. Also, aren't you only getting one result? If so, use query_first. https://www.vbulletin.com/docs/html/codestandards_sql_query
evenmonkeys
07-31-2012, 02:25 AM
Well, I guess what has me confused.. is that if I were to pull out everything in my plugin and change the entire thing to one line of code:$variable = $post['userid'];This will actually show that user's userid on each individual post. But once I throw the queries in there, it doesn't work for some reason.
How do I use the information I pull from the table if I do that? Right now, I would have something like:$player[field]
Still getting the same error as I switch around my queries.
Fatal error: Call to a member function query() on a non-object in /forums/includes/class_postbit.php(265) : eval()'d code on line 86
You probably need
global $vbulletin;
at the beginning of your code.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.