View Full Version : First Plugin - King of the Forum Modification
yfkamakazi
05-07-2011, 11:22 PM
Hi everyone,
Sorry if this is the wrong forum, but I'm just looking for some suggestions on how to do this.
The idea is to use a hook in the plugin system to insert some HTML into the page when it's writing out a post for a specific user. The idea is:
if ($userID == 42) {
$post .= '<div class="kotf-post"><img alt="King" src="images/king.png" /></div>';
}
Hopefully as simple as this.
The problem is, I know next to nothing about vBulletin, which hook to use (I was thinking 'postbit_display_start'), or what variable to use to insert it into. Am I supposed to search through the code for it?
Sorry for the open-ended question. Any advice you can give would be appreciated.
vbresults
05-08-2011, 11:02 AM
Hi everyone,
Sorry if this is the wrong forum, but I'm just looking for some suggestions on how to do this.
The idea is to use a hook in the plugin system to insert some HTML into the page when it's writing out a post for a specific user. The idea is:
if ($userID == 42) {
$post .= '<div class="kotf-post"><img alt="King" src="images/king.png" /></div>';
}
Hopefully as simple as this.
The problem is, I know next to nothing about vBulletin, which hook to use (I was thinking 'postbit_display_start'), or what variable to use to insert it into. Am I supposed to search through the code for it?
Sorry for the open-ended question. Any advice you can give would be appreciated.
A simpler way to accomplish what you are trying to do is to create a usergroup for this "King" and make him the only member of it.
As far as posts, just make a template edit in postbit (or postbit_legacy if that is what you are using) and wrap the appropriate part with:
<vb:if condition="is_member_of($bbuserinfo, KING_USERGROUP_ID)">
<div class="kotf-post">
<img alt="King" src="images/king.png" />
</vb:if>
<!-- template contents? -->
<vb:if condition="is_member_of($bbuserinfo, KING_USERGROUP_ID)">
</div>
</vb:if>
BirdOPrey5
05-09-2011, 04:05 PM
What lance says about the template edit is the correct way to do this, but I think adding a usergroup is overkill IMO, you can test for an individual userid...
In VB 4.x find the line in the postbit/postbit_legacy template:
{vb:raw post.message}
Right before add the code:
<vb:if condition="$bbuserinfo[userid] == 42">
<div class="kotf-post"><img alt="King" src="images/king.png" />
</vb:if>
right after it add the code:
<vb:if condition="$bbuserinfo[userid] == 42">
</div>
</vb:if>
If it's VB3 the code would be:
Find:
$post[message]
Right before add the code:
<if condition="$bbuserinfo[userid] == 42">
<div class="kotf-post"><img alt="King" src="images/king.png" />
</if>
and after:
<if condition="$bbuserinfo[userid] == 42">
</div>
</if>
vbresults
05-12-2011, 05:27 PM
I considered a userid only, but the reason I suggested a usergroup is so a template edit doesn't need to be made every time there is a new king.
BirdOPrey5
05-14-2011, 12:07 AM
I considered a userid only, but the reason I suggested a usergroup is so a template edit doesn't need to be made every time there is a new king.
I thought Kings were for life? :p
Boofo
05-14-2011, 01:05 AM
I thought Kings were for life? :p
LMAO
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.