We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22446
    • 181 Posts
    Does anyone know how to access the User extended fields when a user posts a comment? I don’t want to display the User’s name I would like to display an Extended Field.
      • 14162
      • 67 Posts
      I’d like to know how to do this too. I’m trying to show the poster’s jobtitle extended field using the Profile snippet.

      Currently I have the following in my quip_comment.tpl chunk:

      <h3>[[+name]] ([[QuipCount? &type=`user` &user=`[[!+author]]`]] posts)<span class="floatr" style="font-size:13px;">[[+createdon]]</span></h3>
      <p>[[!Profile? &user=`[[!+author]]`]] [[!+jobtitle]]</p>
              <p class="bottomgrey marb" style="padding-bottom:30px;">[[+body]]<br/>
      [[+replyUrl:notempty=`<span class="floatr"><a style="font-size:13px;" href="[[+replyUrl]]">[[%quip.reply? &namespace=`quip` &topic=`default`]]</a></span>`]]
      
      </p>
      

      This displays the same jobtitle for all (the last poster basically). I’ve tried all manner of caching variations without success. It must be something to do with the order in which each snippet/chunk loads.
        • 14162
        • 67 Posts
        Bumpity bump - anyone?
          • 14162
          • 67 Posts
          Ok. Figured this out finally.
          [[!Profile? &user=`[[+author]]` &prefix=`.user`]]
          <h3>[[+name]] ([[QuipCount? &type=`user` &user=`[[!+author]]`]] posts)<span class="floatr" style="font-size:13px;">[[+createdon]]</span></h3>
          <p> [[!+user.jobtitle]]</p>
                  <p class="bottomgrey marb" style="padding-bottom:30px;">[[+body]]
          [[+replyUrl:notempty=`<span class="floatr"><a style="font-size:13px;" href="[[+replyUrl]]">[[%quip.reply? &namespace=`quip` &topic=`default`]]</a></span>`]]
           
          </p>

            • 7045
            • 225 Posts
            Profile call, no sh*t. You definitely got me going in the right direction, thanks. The following is what I am using to have my "company name" extended field used. My problem is that anonymous users end up having a company name, which makes sense but is not what I want.

            I guess I need to figure our how to get anonymous working with the extended fields.


            [[!Profile? &user=`[[+author]]` &prefix=`user.`]]
            
            <span class="quip-comment-author">[[+user.companyname]]:</span><br />
            
              • 14162
              • 67 Posts
              I actually found that this doesn't return unique values for each user (something to do with Profile caching within a chunk). So I wrote a separate snippet that does a similar job to Profile and it works fine:
              <?php
              if (!empty($userid)) {
              $user = $modx->getObject('modUserProfile', array('id' => $userid) );
              $extendedfields = $user->get('extended');
              $output = $extendedfields[$field];
              }
              if (isset($output)) { return $output;}
              return $default;

              Call it in the Quip comment chunk thus:
              [[!snippetname? &userid=`[[+author]]` &field=`yourextendedfieldname` &default=`the text you want to appear if field empty or user anonymous`]]
              [ed. note: jimbob72 last edited this post 12 years, 6 months ago.]