Announcement

Collapse
No announcement yet.

Trying to add user profile field to conversation_userinfo template

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

  • [Bug / Issue] Trying to add user profile field to conversation_userinfo template

    So I'm trying to add the user's location (field2) into the conversation_userinfo template. I'm using a hook to hook into this and have the following code in the new template:

    Code:
    {vb:data userInfo, user, fetchProfileInfo, {vb:raw conversation.userid}}
    
    <vb:if condition="$userInfo['customFields']['default']['field2_title']"><div class="profile-info-item">{vb:phrase location}: {vb:raw userInfo.customFields.default.field2_title.val}</div></vb:if>
    When I view the page, the word "Location: " is showing up, but the value is not. It just says "Location:"

    I'm trying to get the actual value of the field, but I'm not seeing how to do it and the .val isnt' working. Anyone have any ideas on that?

  • #2
    This works for me:

    Code:
    {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.field2}</span>
      </li>
    </vb:if>
    Translations provided by Google.

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud demonstration site.
    vBulletin 5 API - Full / Mobile
    Vote for your favorite feature requests and the bugs you want to see fixed.

    Comment


    • #3
      I must be missing something then, as this doesn't work for me. The field doesn't render, so in my case, it means that $userInfo['field2'] is returning false. But $userInfo['customFields']['default']['field2_title'] is returning true. So in my case, my fields are burrowed down a little bit in the array. I just don't know how to get the value of the field. I can get the title, but I dont' know where the actual location that the user inputs is being stored.

      Comment


      • #4
        I am using an unmodified version of vBulletin 5.4.5. If you're using an outdated version, it may be different for you. Though you seem to be checking a static variable of field2_title. This should always equal "location" and therefore be true.

        You can put the site into debug mode and place {vb:debugvardump $userInfo} into your custom template to view the entire array. That is how I modified your code to get the code I have.


        https://www.vbulletin.com/go/vb5debug
        Translations provided by Google.

        Wayne Luke
        The Rabid Badger - a vBulletin Cloud demonstration site.
        vBulletin 5 API - Full / Mobile
        Vote for your favorite feature requests and the bugs you want to see fixed.

        Comment


        • #5
          Thanks for pointing me in the right direction! Got it figured out.

          Comment

          Related Topics

          Collapse

          Working...
          X