Trying to add user profile field to conversation_userinfo template

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • klongdesigns
    New Member
    • Sep 2018
    • 13
    • 5.3.x

    [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?
  • Wayne Luke
    vBulletin Technical Support Lead
    • Aug 2000
    • 74117

    #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

    Comment

    • klongdesigns
      New Member
      • Sep 2018
      • 13
      • 5.3.x

      #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

      • Wayne Luke
        vBulletin Technical Support Lead
        • Aug 2000
        • 74117

        #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.


        Debug mode is useful for development purposes- it is required if you will be creating VB5 Modifications you intend to distribute for others to download. However it is also useful for trouble-shooting issues with your site as debug mode often provides more specific error messages when something goes wrong- as such if you are
        Translations provided by Google.

        Wayne Luke
        The Rabid Badger - a vBulletin Cloud demonstration site.
        vBulletin 5 API

        Comment

        • klongdesigns
          New Member
          • Sep 2018
          • 13
          • 5.3.x

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

          Comment

          Related Topics

          Collapse

          Working...