We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43592
    • 97 Posts
    Hi forum members,

    I try to fill a textarea in Newspublisher over a snippet which works like a charm over jquery

    $( document ).ready(function() {
    $('#np-Bankverbindung').val([[!get_iban]]);
    });
    


    In the snippet I try to reach the logged in User profile extended field "IBAN":
    <?php
    // initialize output;
    $output = true;
    // get the current user name
    $extended = $modx->user->get('extended');
    $output ="'IBAN: '". $extended['iban'];
    
    
    return $output;
    


    But only the text shows up. There must be a problem to reach the extended profile field. I use Newspublisher is in my Login area and get no direct php error.

    Any ideas?

    This question has been answered by BobRay. See the first response.

    • discuss.answer
      • 3749
      • 24,544 Posts
      The extended field is in the user profile, not the user object.

      Try this:

      $extended = $modx->user->Profile->get('extended');


      If that doesn't work, you might have to get the Profile directly:

      $profile = $modx->user->getOne('Profile');
      if ($profile) {
          $extended = $profile->get('extended');
      } else {
         $modx->log(modX::LOG_LEVEL_ERROR, 'could not get user profile');
      }
      


      If you intend to update the extended field in the DB, the second method would probably be better.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 43592
        • 97 Posts
        Wow, that works like a charm.

        I say thank you, thank you again, Bob Ray.

          • 3749
          • 24,544 Posts
          I'm glad I could help. smiley
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting