Hey, this looks familiar... Anyway, I think the reason it isn't working is that $vbulletin->userinfo is the "current" user (the one viewing the page), and you need to look up the ban reason for the user who wrote the post. It might work if you use $post['usergroupid'] and $post['userid'] in place of $vbulletin->userinfo. There's also no reason to put the result in $vbulletin->userinfo['banned_reason_text'] - you could use $post there as well (so maybe just change $vbulletin->userinfo to $post everywhere in that code?).
Another thing you could do is to make a plugin on showthread_query and add the ban reason fields to the main post query (you can add to $hook_query_fields and $hook_query_joins in the plugin - see showthread.php around line 985). But I don't know, maybe if there are few users banned it would actually be faster to only do the query when needed rather than add it to every post. I suppose you could build a cache of ban info so that if a user posts a bunch of times on one page you're not doing the same query over and over.
|