PDA

View Full Version : [vB5] User Profile Fields in the postbit templates


Lynne
10 Apr 2013, 00:12
Using your User Profile Fields on your site

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.


First thing to do is figure out which fields you want to add to your postbit. Go to your Admincp > User Profile Fields > User Profile Field Manager and note both the Field Name (field1, field2, etc) and the Category the field is in (see image 1). The Profile Fields are listed under their Category Title on this page. It should either be "(Uncategorized)" or have some other category listed. To then get the Category ID, go to User Profile Field Categories, click to Edit the category you want the ID of, and it will be listed at the top - id x (see image 2). Uncategorized Categories have no Category ID.

Image 1:
http://www.vbulletin.org/forum/attachment.php?attachmentid=144484&stc=1&d=1365552264

Image 2:
http://www.vbulletin.org/forum/attachment.php?attachmentid=144483&stc=1&d=1365552264

So, now that you have a list of field ids and category ids, you can now easily add them to your postbit.

First make sure your hook system is active (it is turned off by default). Go to Admincp > Settings > Products/Hook System > Enable/Disable Hook System > Yes.

Now, go to Admincp > Products & Hooks > Manage Hooks and click the link that says "[Add New Hook]". In that new hook, set the following:

Hook is Active: Yes
Hook Location: conversation_userstats
Title: Show Profile Fields in Postbit
Template Name: conversation_fields
Hook Arguments: conversation=conversation
SAVE

Now go to Admincp > Styles & Templates > Style Manager > Add New Template and on that page, set the following:

Title: conversation_fields
Template:
{vb:data userInfo, user, fetchProfileInfo, {vb:raw conversation.userid}}


For each field you want shown, you will need to add this code under that line:
<vb:if condition="$userInfo['fieldX']"><li><label>{vb:phrase fieldX_title}:</label> <span>{vb:raw userInfo.customFields.default.fieldX_title.val}</span></li></vb:if>

Replace the X in "FieldX" (three times) with the fieldid and, if your field is in a Category other than Uncategoried, then replace "default" with "categoryY_title" where Y is the category id.

So, for instance, say I have the following I want to add:
Name Category
field5 (uncategoried)
field7 New Cat(id 1)

Then my template would look like this:
{vb:data userInfo, user, fetchProfileInfo, {vb:raw conversation.userid}}

<vb:if condition="$userInfo['field5']"><li><label>{vb:phrase field5_title}:</label> <span>{vb:raw userInfo.customFields.default.field5_title.val}</span></li></vb:if>

<vb:if condition="$userInfo['field7']"><li><label>{vb:phrase field7_title}:</label> <span>{vb:raw userInfo.customFields.category1_title.field7_title.val}</span}</li></vb:if>


That's it!

If running 5.1.0, there is a code fix to apply here (http://www.vbulletin.com/forum/forum/vbulletin-5-connect/vbulletin-5-connect-questions-problems-troubleshooting/vbulletin-5-support-issues-questions/4029953-problem-with-user-profile-fields).


In the templates, after applying the following change to

core/vb/library/content/text.php

Find


if (!$canseehiddencustomfields)
{
// Get profile fields information
$fieldsInfo = vB_Cache::instance(vB_Cache::CACHE_STD)->read('vBProfileFields');

if (empty($fieldsInfo))
{
$fieldsInfo = $this->assertor->getRows('vBForum:profilefield');
vB_Cache::instance(vB_Cache::CACHE_STD)->write('vBProfileFields', $fieldsInfo, 1440, array('vBProfileFieldsChg'));
}

foreach ($fieldsInfo as $field)
{
$fields['field' . $field['profilefieldid']] = $field['hidden'];
}
}


Change it to:

// Get profile fields information
$fieldsInfo = vB_Cache::instance(vB_Cache::CACHE_STD)->read('vBProfileFields');
if (empty($fieldsInfo))
{
$fieldsInfo = $this->assertor->getRows('vBForum:profilefield');
vB_Cache::instance(vB_Cache::CACHE_STD)->write('vBProfileFields', $fieldsInfo, 1440, array('vBProfileFieldsChg'));
}
foreach ($fieldsInfo as $field)
{
$fields['field' . $field['profilefieldid']] = $field['hidden'];
}

abdobasha2004
12 Apr 2013, 23:41
thanks lynne
great work

Wayne Luke
13 Apr 2013, 16:18
Great tutorial thanks.

greygaming
02 May 2013, 15:12
how would you go about adding the link as an attribute inside of an img tag?

or is it more involved than just chopping up that string and putting it in whatever tags you need?

Lynne
02 May 2013, 18:24
how would you go about adding the link as an attribute inside of an img tag?

or is it more involved than just chopping up that string and putting it in whatever tags you need?
I don't know what you mean at all. Can you give an example? You can change the template up however you want. I was just giving an example to make it look like the other stuff under the avatar, but you may format it/change it however you want.

greygaming
04 May 2013, 00:58
I would like to take the text string from the text field and have it inserted in the href attribute of an anchor tag. I would then use the anchor tag to wrap around an icon.

any thoughts?

thanks for the reply

Lynne
04 May 2013, 04:16
I would like to take the text string from the text field and have it inserted in the href attribute of an anchor tag. I would then use the anchor tag to wrap around an icon.

any thoughts?

thanks for the reply
So you aren't talking about using a profile field at all, but the text. That isn't what this tutorial is about.

greygaming
04 May 2013, 13:18
okay.

official vbulletin support pointed me here and said it could be done.

thanks anyway

--------------- Added 1367674280 at 1367674280 ---------------

I am unable to create new articles on this site, and vBulletin support is no help.

Would you have any information or resources that I could read up on this topic by myself?

I'm just getting surprised at this point by the lack of help and resources on modifying vbulletin 5.

Lynne
04 May 2013, 19:29
okay.

official vbulletin support pointed me here and said it could be done.

thanks anyway

--------------- Added 1367674280 at 1367674280 ---------------

I am unable to create new articles on this site, and vBulletin support is no help.

Would you have any information or resources that I could read up on this topic by myself?

I'm just getting surprised at this point by the lack of help and resources on modifying vbulletin 5.
This article is about using the Profile Fields in the postbit template. If that is what you are talking about, then it isn't apparent to me. Perhaps you can be a lot more specific about what you want and then we could help. Vague questions will not get very specific responses.

greygaming
05 May 2013, 18:27
I'm sorry for crappy explanations, I do appreciate you taking the time to read these posts


http://imgur.com/rbTHBpa

The picture above is the postbit I am looking to create.
Each image is tied to a link, each link is just the contents of the corresponding profile field.
What I am asking is how to make the output an image of my choice, and have the contents of the field be the link for the image.
Does that make sense?


Isn't that essentially what this tutorial is about, minus the images?
(note: I don't need help with the styling, I can figure that out)

sorry for any misunderstanding or time wasted, i did not mean to offend

Lynne
05 May 2013, 19:34
If your profile field is a link - http://something.com/image.png - then just use an image tag:

<img src="{vb:raw userInfo.customFields.category1_title.field7_title.val}" alt="something" height="yy" width="xx" />

greygaming
05 May 2013, 19:42
gorgeous.


thank you so much for your help

--------------- Added 1367785526 at 1367785526 ---------------

Now, I'm actually curious if there is a way to do the exact same thing in the profile area.

Instead of the field.value being displayed on the profile page, could it be replaced with an image in the exact same way as in the postbit template?

thanks for placating my curiosity!

Lynne
05 May 2013, 23:19
gorgeous.


thank you so much for your help

--------------- Added 1367785526 at 1367785526 ---------------

Now, I'm actually curious if there is a way to do the exact same thing in the profile area.

Instead of the field.value being displayed on the profile page, could it be replaced with an image in the exact same way as in the postbit template?

thanks for placating my curiosity!
Sorry I didn't understand at first what you were looking for. I'm glad we were finally able to get it working!

You could probably do something similar on the profile page, but I don't see a hook there so it looks like you would need to edit the widget_profile_sidebar template manually to do it. I haven't looked into it at all, but my guess is the variable names will be different also.

korny
17 May 2013, 16:46
I am getting this error:

Warning: Illegal string offset 'field5' in [path]/includes/adminfunctions_template.php(4638) : eval()'d code on line 3

Not sure what I am missing in the install.

Lynne
17 May 2013, 17:12
I am getting this error:

Warning: Illegal string offset 'field5' in [path]/includes/adminfunctions_template.php(4638) : eval()'d code on line 3

Not sure what I am missing in the install.
And exactly what did you enter into your template? (Use code tags)

korny
22 May 2013, 21:51
{vb:data userInfo, user, fetchProfileInfo, {vb:raw conversation.userid}}

<vb:if condition="$userInfo['field5']"><li><label>{vb:phrase field5_title}:</label> <span>{vb:raw userInfo.customFields.default.field5_title.val}</span></li></vb:if>

Thanks

Lynne
23 May 2013, 02:05
You have two different code sections above, why? Are they in two different templates or what? Is that all that is in the template? And can we get a screenshot of your Field 5 edit page so we can we it's field id and type and category, etc. And did you create the hook and is the plugin system enabled?

korny
23 May 2013, 19:26
Sorry about the 2 code fields. I have the below in the new conversation_fields template

{vb:data userInfo, user, fetchProfileInfo, {vb:raw conversation.userid}}

<vb:if condition="$userInfo['field5']"><li><label>{vb:phrase field5_title}:</label> <span>{vb:raw userInfo.customFields.default.field5_title.val}</span></li></vb:if>

I have added the hook as instructed in this thread.
The hook system is on.
My new field is uncategorized field 5.


145161


Thanks Lynne!

Lynne
23 May 2013, 20:07
Is there some odd text in the text box for that field for the user?

I honestly see nothing wrong with what you have. I'd try removing some of it and seeing if you can see exactly what part of that template is causing the error.

korny
23 May 2013, 21:56
The error I originally posted comes up when I save the template. I haven't added anything else to the template besides an additional_css mod to make the header logo larger. Other than that my vB version is completely default.

How would I go about completely removing what I have done thus far and starting over?

Lynne
24 May 2013, 17:28
Just delete the template and delete the hook and it's gone.

korny
24 May 2013, 23:21
Ok, so I played around with the code to see if I could get it to at least save without any errors. By changing

"$userInfo['field5']"

to

"$userinfo['field5']" (lower case i)

...the template saved and reloaded. Then I changed it back to capital "Info", still got the error but when I clicked Go Back, it pushed through and saved all of a sudden. :confused:

Then the Custom Profile field is displayed in the postbit...but overlapped the Online status button. I added a <br> underneath the conversation_userstats hook in the coversation_userinfo template and it seems to all be working correctly now.

Hopefully this will help the next person!

:erm:

Lynne
25 May 2013, 03:27
Hmmmm, are you sure your hooks are enabled and you have a hook written (and active) exactly like what I wrote?

korny
26 May 2013, 01:07
Yes, hook system is on and the hook is written exactly as you wrote. I don't know that my issue was caused by my error or your mod. By performing a quick search I found 1 other person who had the same issue, but he/she posted on vb.com and was directed here without resolution. The point is that it now works with the only changes being the line break I had to put in to align the postbit correctly. With the amount of errors and bugs I have already encountered with vB5 I can't say I'm surprised!

discover_xs
14 Jun 2013, 09:46
Exactly the same thing here
When creating the template it self
i get this:

Warning: Illegal string offset 'field5' in [path]/includes/adminfunctions_template.php(4704) : eval()'d code on line 2

v. 5.0.2

{vb:data userInfo, user, fetchProfileInfo, {vb:raw conversation.userid}}
<vb:if condition="$userInfo['field5']"><li><label>{vb:phrase field5_title}:</label> <span>{vb:raw userInfo.customFields.default.field5_title.val}</span></li></vb:if>


After saving it with a lower case I
it saved but its not showing up.

Hooks are active and set exactly as instructed.
Template name is the same
everything is the same but it does not show up.
Do i need to add something to conversation_userinfo
to make it show up?


wow i made it work by putting this
{vb:data userInfo, user, fetchProfileInfo, {vb:raw conversation.userid}}
<vb:if condition="$userInfo['field5']"><li><label>{vb:phrase field5_title}:</label> <span>{vb:raw userInfo.customFields.default.field5_title.val}</span></li></vb:if>
in conversation_userinfo
where i want the gender to be displayed.


Now another question:

Field is Gender
and can i set an image to show for each choice?
(male / female signs)

Lynne
14 Jun 2013, 18:28
Very odd. I cannot get it to give me that error at all on either of my test sites when I enter exactly what you guys are entering.

Do you have the plugin system enabled?

As for an image, just use a condition:
<vb:if condition="$userInfo['field5'] == 'female'">image code here
<vb:else /> other image code here
</vb:if>

discover_xs
14 Jun 2013, 19:33
nope.
nothing ON right now

hmmm... really strange

check your pm
some private details there.

if we find a solution it will be posted ;)



thank you for the IMG thing .. i will check it as soon as possible and report back to you

Admigo
08 Aug 2013, 12:05
I have a problem with this code.
I made a text profile field but only the title is showing in the postbit.
Example: CnR Username :
I already changed the CnR Username in my profile.
How to fix it for not showing as blank?

Lynne
08 Aug 2013, 21:23
Post your exact code or it's impossible to help.

Admigo
08 Aug 2013, 21:27
Post your exact code or it's impossible to help.
Here you go:
{vb:data userInfo, user, fetchProfileInfo, {vb:raw conversation.userid}}
<vb:if condition="$userInfo['field5']"><li><label>{vb:phrase field5_title}:</label> <span>{vb:raw userInfo.customFields.category5_title.field5_title.val}</span></li></vb:if>

Lynne
08 Aug 2013, 21:34
And you are positive the catid is 5?

Admigo
08 Aug 2013, 21:39
And you are positive the catid is 5?
Yes. User Profile Field: CnR Username (id: 5 - input)
The title is showing fine in the postbit but not my CnR Username.
So CnR Username : blank

EDIT: I fixed it. I didnt made a category. Thanks for your help.

astrid1
12 Aug 2013, 09:26
Also have problems in 5.0.3 there was no problem
now 5.04 based on a new installtion I get this error

Warning: Illegal string offset 'field5' in [path] / includes / adminfunctions_template.php (4723): eval () 'd code on line 2

Lynne
12 Aug 2013, 17:41
Post your exact template. And did you make sure to enable the plugin system (it is off by default) and create the Hook?

astrid1
13 Aug 2013, 10:19
{vb:data userInfo, user, fetchProfileInfo, {vb:raw conversation.userid}}

<vb:if condition="$userInfo['field5']"><li><label>{vb:phrase field5_title}:</label> <span>{vb:raw userInfo.customFields.default.field5_title.val}</span></li></vb:if>

<vb:if condition="$userInfo['field7']"><li><label>{vb:phrase field7_title}:</label> <span>{vb:raw userInfo.customFields.category1_title.field7_title.val}</span}</li></vb:if>


The following error occurred when attempting to evaluate this template:

Warning: Illegal string offset 'field2' in [path]/includes/adminfunctions_template.php(4723) : eval()'d code on line 3

Warning: Illegal string offset 'field7' in [path]/includes/adminfunctions_template.php(4723) : eval()'d code on line 9

This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wis

and since the error message is the temple will not be stored

astrid1
23 Sep 2013, 11:37
Lynne?

Lynne
23 Sep 2013, 17:17
That is my example template. I doubt yours would be exactly the same. Post images of your admincp > User Profile Field Manager and the Categories.

heredia21
08 Dec 2013, 05:56
Perfect Lynne! Just what I was looking for. We need some more of these how-tos!

ndut
12 Jan 2014, 14:49
@Lynne,

my command :

{vb:data userInfo, user, fetchProfileInfo, {vb:raw conversation.userid}}

<vb:if condition="$userInfo['field2']"><li><label>{vb:phrase field2_title}:</label> <span>{vb:raw userInfo.customFields.default.field2_title.val}</span></li></vb:if>

<vb:if condition="$userInfo['field3']"><li><label>{vb:phrase field3_title}:</label> <span>{vb:raw userInfo.customFields.default.field3_title.val}</span></li></vb:if>

and the error message is :

The following error occurred when attempting to evaluate this template:

Warning: Illegal string offset 'field2' in [path]/includes/adminfunctions_template.php(4738) : eval()'d code on line 3

Warning: Illegal string offset 'field3' in [path]/includes/adminfunctions_template.php(4738) : eval()'d code on line 9

This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish.

what should i do?


That is my example template. I doubt yours would be exactly the same. Post images of your admincp > User Profile Field Manager and the Categories.
and this is my screen shot :
http://www.vbulletin.org/forum/attachment.php?attachmentid=147797&stc=1&d=1389543242

ndut
23 Jan 2014, 14:44
Hello, Lynne.....

Lynne
23 Jan 2014, 17:58
I would suggest reading the thread and trying the suggestions users have posted already regarding that error.

nchoose
24 Feb 2014, 01:55
Lynne, Here is my code:

{vb:data userInfo, user, fetchProfileInfo, {vb:raw conversation.userid}}
<vb:if condition="$userInfo['field6']"><li><label>{vb:phrase field6_title}:</label> <span>{vb:raw userInfo.customFields.default.field6_title.val}</span></li></vb:if>

It is working perfectly to show TEXT put in the field. I would like to put a URL in the field and have the word Feedback linked to that URL. Can you help. This seems like I should be able to do it easy peasy... and my mind is drawing a blank. TY TY

--------------- Added 1393213800 at 1393213800 ---------------

LYNNE! You ROCK! Ok, I figured it out! I was also able to add a second value after the link! *YAY* *YAY* {vb:data userInfo, user, fetchProfileInfo, {vb:raw conversation.userid}}
<vb:if condition="$userInfo['field6']"><li><label><a href={vb:raw userInfo.customFields.default.field6_title.val}>{vb:phrase field6_title}</a>:</label> <span>{vb:raw userInfo.customFields.default.field7_title.val}</span></li></vb:if>

http://whatsyourdeal.com/grocery-coupons/wp-content/uploads/2014/02/Capture118.jpg

we will have to manually update these values, but until there is a mod, this will work. Muddling through!

Thanks again LYNNE for your help!

Lynne
24 Feb 2014, 03:18
I'm glad you got it working. :)

Spangle
20 Apr 2014, 11:06
Tried this on a 5.0.5 and it broke the board !

"There is a serious error and the page cannot be rendered"

Deleted hook

Disabled hook system, board still not functioning

Lynne
20 Apr 2014, 16:35
Not sure exactly what you did, but this is only a hook and it seems strange that it would cause that sort of error. You can go into debug mode and see what the real error is. Also, don't forget to Clear System Cache after doing something.

Spangle
20 Apr 2014, 20:18
Not sure exactly what you did, but this is only a hook and it seems strange that it would cause that sort of error. You can go into debug mode and see what the real error is. Also, don't forget to Clear System Cache after doing something.

I couldn't do anything, not even get into the ACP, every URL was met with the same error, the only way out was to upgrade to 5.1.0.

I tried the same in 5.1.0, and the same thing happened, eventually gave up on it, is there an easier way to add these fields to the postbit ?

Lynne
21 Apr 2014, 17:20
Why don't you post screen shots of *exactly* what you did.

Spangle
21 Apr 2014, 18:32
I'm confident I followed your instructions correctly, I'm hesitant to go through the process again, in case I "break" the forum again.

You would think there would be an easier way to incorporate fields into postbit.

Spangle
23 Apr 2014, 13:05
BTW this link:

http://www.vbulletin.com/docs/html/profile


gives a "Page not found" response

--------------- Added 1398260380 at 1398260380 ---------------

Attempted this again, followed the instructions to the letter.

Exactly the same result.

There is a serious error and the page cannot be rendered

Would advise that users of 5.0.5 and 5.1.0 do not use this until a fix is posted.

Lynne
23 Apr 2014, 16:46
Please see this thread - http://www.vbulletin.com/forum/forum/vbulletin-5-connect/vbulletin-5-connect-questions-problems-troubleshooting/vbulletin-5-support-issues-questions/4029953-problem-with-user-profile-fields

Spangle
31 Jul 2014, 10:00
I'm using 5.1.3 A6 and I still cannot get this to display the profile fields, here is the code I am using in the template conversation_fields

{vb:data userInfo, user, fetchProfileInfo, {vb:raw conversation.userid}}

<vb:if condition="$userInfo['field5']"><li><label>{vb:phrase field5_title}:</label> <span>{vb:raw userInfo.customFields.default.field5_title.val}</span></li></vb:if>

<vb:if condition="$userInfo['field2']"><li><label>{vb:phrase field2_title}:</label> <span>{vb:raw userInfo.customFields.default.field2_title.val}</span></li></vb:if>

Lynne
31 Jul 2014, 17:28
I just put your code into the template on my site and it works just fine.

If you are still getting the This is a Serious Error message on your page, then go into debug mode and see what the real error is.

To enable debug mode edit the /config.php file and change:

$config['debug'] = false;
To:
$config['debug'] = true;

Then edit the /core/includes/config.php file and change:

// $config['Misc']['debug'] = true;
To:
$config['Misc']['debug'] = true;

To set that up for only your IP address (replace xxx.xxx.xxx.xxx with your IP), put these lines around the code:

if($_SERVER['REMOTE_ADDR'] == "xxx.xxx.xxx.xxx") {
CODE HERE
}

DisasterDotCom
10 Aug 2014, 03:16
How would I display a piece of information in the postbit only if the user VIEWING the page is logged in and in the supermoderator or admin user group?

--------------- Added 1407644438 at 1407644438 ---------------

Actually, I think I got it... but this could probably be cleaned up... I'm also not 100% sure membergroupids is an array? This is vb5.1.2

<vb:if condition="in_array($bbuserinfo[usergroupid], array(5,6,16))">
<vb:if condition="in_array($userInfo['membergroupids'], array(14,15))">
<span style="color:red;font-weight:bold;">Display Stuff Here</span><br>
</vb:if>
</vb:if>

--------------- Added 1407645650 at 1407645650 ---------------

And one more update... userinfo['membergroupids'] shows up as a string when I do a debugvardump. How do I check to see if it contains the group ID? vBulletin doesn't allow you to search in a string according to http://bit.ly/1uBdO1U

Lynne
10 Aug 2014, 16:54
I believe is_member_of is the function your would want to use.

<vb:if condition="is_member_of($bbuserinfo, 5, 6, 16)">
<vb:if condition="is_member_of($userInfo, 14, 15)">

DesignMVD
03 Sep 2014, 04:11
Thanks for the tutorial!

I show my result :)

vvlo
04 Sep 2014, 05:32
hi
I can not find Admincp > Styles & Templates > Style Manager > Add New Template
Instead There is : Add New style
And there is no place to add code

Lynne
04 Sep 2014, 18:04
Add New Template is a dropdown next to the style. The default dropdown will say Style Variable Editor, so just click on that to see the other options.

vvlo
04 Sep 2014, 19:05
Add New Template is a dropdown next to the style. The default dropdown will say Style Variable Editor, so just click on that to see the other options.

i use vBulletin Default Theme, and not see this option in dropdown.:(

dropdown option :edit setting
add child style
download
delete style

I added a child style and did change it and the problem was solved.
Thank you.

raynestorm
16 Mar 2015, 21:51
Hello--
I am following this tutorial and have created a new category called "Custom" and added a new field called "industry". "Industry" has several check boxes for the user to check. The "Custom" category has ID = 1 and the industry field is field=5. I created and added this code to a template called "conversation_fields":

{vb:data userInfo, user, fetchProfileInfo, {vb:raw conversation.userid}}
<vb:if condition="$userInfo['field5']"><li><label>{vb:phrase field5_title}:</label> <span>{vb:raw userInfo.customFields.category1_title.field5_title.val}</span></li></vb:if>


The word "Industry: " displays in my postpit but the values (picked by checkbox) do not display. How can I get the value of the field "Industry" to also be displayed?

Thanks.

Lynne
17 Mar 2015, 19:16
That looks like it should work. Can I get a screen shot of your profile field 5?

raynestorm
17 Mar 2015, 19:58
Attached are the screen shots.
Thanks.

Lynne
18 Mar 2015, 22:09
For the option, you cut off the screen right where it says Display Page - do you have it set to Edit Profile? I think it needs to be for this to work.

raynestorm
18 Mar 2015, 23:01
For the option, you cut off the screen right where it says Display Page - do you have it set to Edit Profile? I think it needs to be for this to work.

You are right! It does have to be set to Edit Profile. I had set it to "Other", but I can't remember why, exactly. Display Page only controls where the field contents is displayed?

Thanks for the help!

arshadeomran
27 Apr 2015, 17:47
Using your User Profile Fields on your site

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.


First thing to do is figure out which fields you want to add to your postbit. Go to your Admincp > User Profile Fields > User Profile Field Manager and note both the Field Name (field1, field2, etc) and the Category the field is in (see image 1). The Profile Fields are listed under their Category Title on this page. It should either be "(Uncategorized)" or have some other category listed. To then get the Category ID, go to User Profile Field Categories, click to Edit the category you want the ID of, and it will be listed at the top - id x (see image 2). Uncategorized Categories have no Category ID.

Image 1:
http://www.vbulletin.org/forum/attachment.php?attachmentid=144484&stc=1&d=1365552264

Image 2:
http://www.vbulletin.org/forum/attachment.php?attachmentid=144483&stc=1&d=1365552264

So, now that you have a list of field ids and category ids, you can now easily add them to your postbit.

First make sure your hook system is active (it is turned off by default). Go to Admincp > Settings > Products/Hook System > Enable/Disable Hook System > Yes.

Now, go to Admincp > Products & Hooks > Manage Hooks and click the link that says "[Add New Hook]". In that new hook, set the following:

Hook is Active: Yes
Hook Location: conversation_userstats
Title: Show Profile Fields in Postbit
Template Name: conversation_fields
Hook Arguments: conversation=conversation
SAVE

Now go to Admincp > Styles & Templates > Style Manager > Add New Template and on that page, set the following:

Title: conversation_fields
Template:
{vb:data userInfo, user, fetchProfileInfo, {vb:raw conversation.userid}}


For each field you want shown, you will need to add this code under that line:
<vb:if condition="$userInfo['fieldX']"><li><label>{vb:phrase fieldX_title}:</label> <span>{vb:raw userInfo.customFields.default.fieldX_title.val}</span></li></vb:if>

Replace the X in "FieldX" (three times) with the fieldid and, if your field is in a Category other than Uncategoried, then replace "default" with "categoryY_title" where Y is the category id.

So, for instance, say I have the following I want to add:
Name Category
field5 (uncategoried)
field7 New Cat(id 1)

Then my template would look like this:
{vb:data userInfo, user, fetchProfileInfo, {vb:raw conversation.userid}}

<vb:if condition="$userInfo['field5']"><li><label>{vb:phrase field5_title}:</label> <span>{vb:raw userInfo.customFields.default.field5_title.val}</span></li></vb:if>

<vb:if condition="$userInfo['field7']"><li><label>{vb:phrase field7_title}:</label> <span>{vb:raw userInfo.customFields.category1_title.field7_title.val}</span}</li></vb:if>


That's it!

If running 5.1.0, there is a code fix to apply here (http://www.vbulletin.com/forum/forum/vbulletin-5-connect/vbulletin-5-connect-questions-problems-troubleshooting/vbulletin-5-support-issues-questions/4029953-problem-with-user-profile-fields).
Hi Lynne,
I want to place the new fields of postbit below number of post.
How can I do it?
Thanks

Lynne
27 Apr 2015, 18:53
Hi Lynne,
I want to place the new fields of postbit below number of post.
How can I do it?
Thanks
There isn't a hook there, so you would need to add the code directly to the template.

arshadeomran
28 Apr 2015, 08:43
There isn't a hook there, so you would need to add the code directly to the template.

I have used the codes that you wrote in first post. I want only change position of field in postbit so that "number of post" must be the latest field not second field.
Thank you.

heredia21
05 Jul 2015, 18:59
Does this no longer working on 5.1.8 Alpha 6? All of a sudden the extra profile fields stopped showing.