Announcement

Collapse
No announcement yet.

Use Custom Profile Fields in Conversation Userinfo Template

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Use Custom Profile Fields in Conversation Userinfo Template

    This post 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. and will be using the Hook system rather than Template Edits to achieve this

    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 ONLY

    Firstly, go to:

    AdminCP > Styles & Themes > Style Manager

    ...and using the dropdown next to your chosen Style, select 'Add New Template'. Name this template 'conversation_profilefields' and add the following to the template code:

    PHP Code:
    {vb:data userInfouserfetchProfileInfo, {vb:raw conversation.userid}}

    <
    vb:if condition="$userInfo['fieldx']"><li class="b-userinfo__additional-info"><label>{vb:phrase fieldx_title}:</label> <span>{vb:raw userInfo.customFields.default.fieldx_title.val}</span></li></vb:if> 
    Change the three instances of "fieldx" to your actual field name then save this template. For multiple fields, repeat the <vb:if> </vb:if> line changing the "fieldx" to the appropriate field ID.

    Next, go to:

    AdminCP > Products & Hooks > Manage Hooks

    ...and click on the 'Add New Hook' link. Create a new hook with these specifications:
    • Product: vBulletin
    • Hook is Active: Yes
    • Hook Location: conversation_userstats
    • Title: Add User Profile Fields to Conversation Userinfo Template
    • Template Name: conversation_profilefields

    Save this Hook. Now, provided you have text in the relevant Profile Field, these will show up underneath the number of posts a user has when the relevant profile field is completed by the user.

    Instructions for Multiple-Selection Menu and Multiple-Selection Checkbox fields will follow later...
    Last edited by Trevor Hannant; Wed 21 Oct '15, 5:44am.
    Vote for:

    - *Admin Settable Paid Subscription Reminder Timeframe*
    -
    *PM - Add ability to reply to originator only*
    - Add Admin ability to auto-subscribe users to specific channel(s)
    - "Quick Route" Interface...

  • #2
    For styling purposes and to make it consistent with other items in the postbit, the <li> tag should have b-userinfo__additional-info class.

    GIPHY for vB5 AutoLinker Auto-Create Flag Report Topic Social Icons in Postbit Clear Cache Cron DragDrop Upload Topic AJAX AutoUpdate Custom Avatars Selector Stop Links in Posts...and more!

    Comment


    • #3
      Don't know why I missed that... Thanks Glenn!
      Vote for:

      - *Admin Settable Paid Subscription Reminder Timeframe*
      -
      *PM - Add ability to reply to originator only*
      - Add Admin ability to auto-subscribe users to specific channel(s)
      - "Quick Route" Interface...

      Comment


      • #4
        Well this put MY location under everyone, it did not show each individual users location. Ideas???

        Comment


        • #5
          Try this:

          1. Edit the hook you created and in the Hook Arguments field, specify the following:

          Code:
          userInfo=userInfo
          2. Edit the template you created and replace this:

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

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

          GIPHY for vB5 AutoLinker Auto-Create Flag Report Topic Social Icons in Postbit Clear Cache Cron DragDrop Upload Topic AJAX AutoUpdate Custom Avatars Selector Stop Links in Posts...and more!

          Comment


          • #6
            Originally posted by Trevor Hannant View Post
            For multiple fields, repeat the <vb:if> </vb:if> line changing the "fieldx" to the appropriate field ID.
            This is how I would do it.

            PHP Code:
            {vb:rawdata userInfouserfetchProfileInfo, {vb:raw userInfo.userid}}

            <
            vb:comment>Specify the custom field IDsYou can re-arrange the order as desired</vb:comment>
            {
            vb:set fields, {vb:php array, field5field6field7field8field9field10}}

            <
            vb:each from="fields" value="field">
                {
            vb:set label, {vb:raw field}}
                {
            vb:strcat label'_title'}
                {
            vb:set fieldVal, {vb:raw userInfo[$field]}}
                <
            vb:if condition="!empty($fieldVal)">
                    <
            li class="b-userinfo__additional-info"><label>{vb:phrase {vb:raw label}}:</label> <span>{vb:var fieldVal}</span></li>
                </
            vb:if>
            </
            vb:each>

            <
            vb:comment>Bonus! if you want to add a Send PM link</vb:comment>
            <
            li class="b-userinfo__additional-info"><a href="{vb:raw baseurl}/privatemessage/new/{vb:raw userInfo.userid}">Send PM</a></li
            I would still use it even if only one profile field is needed because this will only require adding fieldX once instead of 3 instances.
            Last edited by Glenn Vergara; Wed 21 Oct '15, 1:08pm.

            GIPHY for vB5 AutoLinker Auto-Create Flag Report Topic Social Icons in Postbit Clear Cache Cron DragDrop Upload Topic AJAX AutoUpdate Custom Avatars Selector Stop Links in Posts...and more!

            Comment


            • #7
              Originally posted by Glenn Vergara View Post
              Try this:

              1. Edit the hook you created and in the Hook Arguments field, specify the following:

              Code:
              userInfo=userInfo
              2. Edit the template you created and replace this:

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

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

              Worked, THANK YOU!!

              Comment


              • #8
                Thanks guys.. worked for me also with hook & template edit.. I too had it show up for all users.. Maybe Trevor can update the original post?

                Best,
                Stan

                Comment


                • #9
                  Originally posted by Glenn Vergara View Post
                  This is how I would do it.

                  PHP Code:
                  {vb:rawdata userInfouserfetchProfileInfo, {vb:raw userInfo.userid}}

                  <
                  vb:comment>Specify the custom field IDsYou can re-arrange the order as desired</vb:comment>
                  {
                  vb:set fields, {vb:php array, field5field6field7field8field9field10}}

                  <
                  vb:each from="fields" value="field">
                  {
                  vb:set label, {vb:raw field}}
                  {
                  vb:strcat label'_title'}
                  {
                  vb:set fieldVal, {vb:raw userInfo[$field]}}
                  <
                  vb:if condition="!empty($fieldVal)">
                  <
                  li class="b-userinfo__additional-info"><label>{vb:phrase {vb:raw label}}:</label> <span>{vb:var fieldVal}</span></li>
                  </
                  vb:if>
                  </
                  vb:each>

                  <
                  vb:comment>Bonus! if you want to add a Send PM link</vb:comment>
                  <
                  li class="b-userinfo__additional-info"><a href="{vb:raw baseurl}/privatemessage/new/{vb:raw userInfo.userid}">Send PM</a></li
                  I would still use it even if only one profile field is needed because this will only require adding fieldX once instead of 3 instances.
                  Just updating this thread that I made this solution of mine as a real mod for easy installation and maintenance.

                  http://vbmods.rocks/forum/vbulletin-...lds-in-postbit

                  GIPHY for vB5 AutoLinker Auto-Create Flag Report Topic Social Icons in Postbit Clear Cache Cron DragDrop Upload Topic AJAX AutoUpdate Custom Avatars Selector Stop Links in Posts...and more!

                  Comment


                  • #10
                    Originally posted by Trevor Hannant View Post
                    This post 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. and will be using the Hook system rather than Template Edits to achieve this

                    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 ONLY

                    Firstly, go to:

                    AdminCP > Styles & Themes > Style Manager

                    ...and using the dropdown next to your chosen Style, select 'Add New Template'. Name this template 'conversation_profilefields' and add the following to the template code:

                    PHP Code:
                    {vb:data userInfouserfetchProfileInfo, {vb:raw conversation.userid}}

                    <
                    vb:if condition="$userInfo['fieldx']"><li class="b-userinfo__additional-info"><label>{vb:phrase fieldx_title}:</label> <span>{vb:raw userInfo.customFields.default.fieldx_title.val}</span></li></vb:if> 
                    Change the three instances of "fieldx" to your actual field name then save this template. For multiple fields, repeat the <vb:if> </vb:if> line changing the "fieldx" to the appropriate field ID.

                    Next, go to:

                    AdminCP > Products & Hooks > Manage Hooks

                    ...and click on the 'Add New Hook' link. Create a new hook with these specifications:
                    • Product: vBulletin
                    • Hook is Active: Yes
                    • Hook Location: conversation_userstats
                    • Title: Add User Profile Fields to Conversation Userinfo Template
                    • Template Name: conversation_profilefields

                    Save this Hook. Now, provided you have text in the relevant Profile Field, these will show up underneath the number of posts a user has when the relevant profile field is completed by the user.

                    Instructions for Multiple-Selection Menu and Multiple-Selection Checkbox fields will follow later...
                    Hello Trevor

                    With the original field works fine, but with my custom field only appear the name of field.

                    Example:
                    • Fecha de ingreso:
                    • Mensajes: 819
                    • Name:
                    • Genre:
                    In field "Name:" not appear any name and in field "Genre:" same not appear any info.

                    It is worth clarifying that I was edited the field fieldx in the 3 instances.

                    My code:

                    PHP Code:
                    {vb:data userInfouserfetchProfileInfo, {vb:raw conversation.userid}}

                    <
                    vb:if condition="$userInfo['field7']"><li class="b-userinfo__additional-info"><label>{vb:phrase field7_title}:</label> <span>{vb:raw userInfo.customFields.default.field7_title.val}</span></li></vb:if>

                    <
                    vb:if condition="$userInfo['field5']"><li class="b-userinfo__additional-info"><label>{vb:phrase field5_title}:</label> <span>{vb:raw userInfo.customFields.default.field5_title.val}</span></li></vb:if> 
                    Thanks for your help

                    Comment


                    • #11
                      Resolved with the following code:

                      PHP Code:
                      <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> 
                      Thanks anyway

                      Comment

                      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                      Working...
                      X