View Full Version : Probably a simple problem but... I need help.
sccrgy789
08-06-2008, 12:27 AM
I have a product which forms a variable in a plugin using the postbit_display_start hook:
$someVar = "whatever" . $post[userid];
Then, I echo this string in my "postbit" using $someVar in the template.
This works completely fine and it echos and works properly.
However, when it comes to viewing a private message, it screws up. For some reason, when postbit_display_start executes, it ends up using the user id of the person VIEWING the PM, not of the person who the PM is from...
What I need is to basically have a string (for both viewing posts/threads AND for viewing PMs) which has the poster's/sender's user ID in it.
Dismounted
08-06-2008, 06:41 AM
Can't you just put this in the template itself?
whatever$post[userid]
sccrgy789
08-06-2008, 11:17 AM
No because I'm using the userid to create an image path in the plugin.
For example:
$imagePath = $someOtherVar . $post[userid] . ".jpg";
I just don't get why when the postbit hook is used for a post, $post[userid] is the poster's ID but when you use the hook for private messages, $post[userid] ends up being the currently logged in user viewing the PM.
Opserty
08-06-2008, 12:44 PM
I'm not sure why that would occur. Does
$post['userid']
Work? Or:
$post['fromuserid']
As a last resort check the PHP code in the file located around the hook it may give you clues as to which variable to use.
sccrgy789
08-06-2008, 05:03 PM
$post['userid']
is what i'm using and it only works for posts.
$post['fromuserid']
would probably work but only for PMs.
I suppose if there's a way to determine whether a PM or Post is being viewed in the plugin, I could assign the proper variable.
BUT still: why is vBulletin using MY userid for $post['userid'] in the plugin and only for PMs? It doesn't really make any sense.
sccrgy789
08-07-2008, 11:37 PM
This is still an issue... can anyone help?
RLShare
08-08-2008, 12:09 AM
$post['fromuserid'] would not be set in a thread so use a conditional checking if a value is set for $post['fromuserid'] and use that id if it is and an else clause using the other if it is not set
Opserty
08-08-2008, 09:40 AM
I really doubt vBulletin would load your UserID into the $post['userid'], are you sure you not viewing a PM you sent to yourself or something? (Look at the variable vBulletin uses when it links your username to the profile. It uses $post['userid'], maybe if you tried moving the hook to postbit_display_complete and used $this->post['userid'] ?).
If it still doesn't work post the full code you are using.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.