This article is written with the assumption that you have already created your own User Profile Fields in the User Profile Field Manager. If you need help with this, you may read about it in the manual here - http://www.vbulletin.com/docs/html/profile
For the Purposes of this article, I will be referring to "fieldx" as the name of your profile field. Your real name will be found in the User Profile Manager in the "Name" column - field1, field2, etc.
Adding the Profile Field to your postbit (or postbit_legacy) template
For Single-Line Text Box, Multiple-Line Text Box, Single-Selection Radio Buttons, and Single-Selection Menu
Method 1 - Modifying the Template
It is a bit more complicated for these two types of selections since the options selected are stored as a binary number. If you just display the field using the method above, you will get a number, not a list of options selected. So, in order to use these types of fields, you will have to use the method below. Here is a thead that will explain the binary scheme - http://www.vbulletin.com/forum/showt...To-The-Postbit
Method 1 - Modifying the Template
For the Purposes of this article, I will be referring to "fieldx" as the name of your profile field. Your real name will be found in the User Profile Manager in the "Name" column - field1, field2, etc.
Adding the Profile Field to your postbit (or postbit_legacy) template
For Single-Line Text Box, Multiple-Line Text Box, Single-Selection Radio Buttons, and Single-Selection Menu
Method 1 - Modifying the Template
Open the postbit or postbit_legacy template and find the area you want to add it to. For instance, to add it right after the user post count, find this:
And then, add this underneath:
Change "fieldx" to your actual field name and the green field to whatever you want. Notice the html I used is similar to the html used for the text above me new field.
Method 2 - Using a template_hookCode:
<dt>{vb:rawphrase 'posts'}</dt> <dd>{vb:raw post.posts}</dd>
Code:
<vb:if condition="$post['[COLOR=red]fieldx[/COLOR]']"><dt>[COLOR=green]My FieldX[/COLOR]</dt> <dd>{vb:raw post.[COLOR=red]fieldx[/COLOR]}</dd></vb:if>
I have always found it easier to just use the existing $template_hooks in the template and write a plugin to add these. In this case, there is a $template_hook right where we want it, after the user post count:
So, we would create a plugin with these specifications:
• hook location - postbit_display_complete
• Title - Add User Profile Fields to Postbit Templates
• Plugin is Active - Yes
• Plugin PHP Code -
Change "fieldx" to your actual field name and the green field to whatever you want. Again, notice the html I used is similar to the html used for the text above me new field. Whichever template_hook you use, you should look at the template to see what sort of html is being used around the hook so that you may use similar, proper html also.
For Multiple-Selection Menu and Multiple-Selection CheckboxCode:
{vb:raw template_hook.postbit_userinfo_right_after_posts}
• hook location - postbit_display_complete
• Title - Add User Profile Fields to Postbit Templates
• Plugin is Active - Yes
• Plugin PHP Code -
Code:
if ($post['[COLOR=red]fieldx[/COLOR]']) { $template_hook['postbit_userinfo_right_after_posts'] .= '<dt>[COLOR=green]My FieldX[/COLOR]</dt> <dd>' .$post[[COLOR=red]fieldx[/COLOR]]. '</dd>'; }
It is a bit more complicated for these two types of selections since the options selected are stored as a binary number. If you just display the field using the method above, you will get a number, not a list of options selected. So, in order to use these types of fields, you will have to use the method below. Here is a thead that will explain the binary scheme - http://www.vbulletin.com/forum/showt...To-The-Postbit
Method 1 - Modifying the Template
Open the template and find the area you want to add it to. For instance, to add it right after the user post count, find this:
And then add this underneath (this is assuming the field has 5 options):
Change "fieldx" to your actual field name and the green field to whatever you want. Notice the html I used is similar to the html used for the text above me new field.
Method 2 - Using a template_hookCode:
<dt>{vb:rawphrase 'posts'}</dt> <dd>{vb:raw post.posts}</dd>
Code:
<vb:if condition="$post['[COLOR=red]fieldx[/COLOR]']"><dt>[COLOR=green]My FieldX[/COLOR]</dt><dd> <vb:if condition="$post['[COLOR=red]fieldx[/COLOR]'] & 1">[COLOR=green]Your 1rst option[/COLOR]</vb:if> <vb:if condition="$post['[COLOR=red]fieldx[/COLOR]'] & 2">[COLOR=green]Your 2nd option[/COLOR]</vb:if> <vb:if condition="$post['[COLOR=red]fieldx[/COLOR]'] & 4">[COLOR=green]Your 3rd option[/COLOR]</vb:if> <vb:if condition="$post['[COLOR=red]fieldx[/COLOR]'] & 8">[COLOR=green]Your 4th option[/COLOR]</vb:if> <vb:if condition="$post['[COLOR=red]fieldx[/COLOR]'] & 16">[COLOR=green]Your 5th option[/COLOR]</vb:if> </dd> </vb:if>
Find the template_hook you want to use. In this case, there is a $template_hook right where we want it, after the user post count:
So, we would create a plugin with these specifications:
• hook location - postbit_display_complete
• Title - Add User Profile Fields to Postbit Templates
• Plugin is Active - Yes
• Plugin PHP Code -
Change "fieldx" to your actual field name and the green field to whatever you want. Again, notice the html I used is similar to the html used for the text above me new field. Whichever template_hook you use, you should look at the template to see what sort of html is being used around the hook so that you may use similar, proper html also.
I do provide an all-plugin method to spit out your Multiple-Selection Menu and Multiple-Selection Checkbox profile fields at the bottom of this article over on vbulletin.org - Using your User Profile Fields in your postbit templates (w/ all plugin method)
Code:
{vb:raw template_hook.postbit_userinfo_right_after_posts}
• hook location - postbit_display_complete
• Title - Add User Profile Fields to Postbit Templates
• Plugin is Active - Yes
• Plugin PHP Code -
Code:
if ($post['[COLOR=red]fieldx[/COLOR]']) { $template_hook['postbit_userinfo_right_after_posts'] .= '<dt>[COLOR=green]My FieldX[/COLOR]</dt> <dd>'; if ($post['[COLOR=red]fieldx[/COLOR]'] & 1) $template_hook['postbit_userinfo_right_after_posts'] .= '[COLOR=green]Your 1rst option[/COLOR]'; if ($post['[COLOR=red]fieldx[/COLOR]'] & 2) $template_hook['postbit_userinfo_right_after_posts'] .= '[COLOR=green]Your 2nd option[/COLOR]'; if ($post['[COLOR=red]fieldx[/COLOR]'] & 4) $template_hook['postbit_userinfo_right_after_posts'] .= '[COLOR=green]Your 3rd option[/COLOR]'; if ($post['[COLOR=red]fieldx[/COLOR]'] & 8) $template_hook['postbit_userinfo_right_after_posts'] .= '[COLOR=green]Your 4th option[/COLOR]'; if ($post['[COLOR=red]fieldx[/COLOR]'] & 16) $template_hook['postbit_userinfo_right_after_posts'] .= '[COLOR=green]Your 5th option[/COLOR]'; $template_hook['postbit_userinfo_right_after_posts'] .= '</dd>'; }