We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37686
    • 94 Posts
    When i update my Profile with extended user attributes, i want to grap the data from this extended user attribute instantly, however.. some cache issues or whatever are preventing me to receive this information.

    example chunk:
    [[UpdateProfile]] 
    [[+login.update_success:if=`[[+login.update_success]] `:is=`1`:then=`[[ %login.profile_updated? &namespace=`login` &topic=`updateprofile`]]`]]
    <form class="form" action="[[~[[*id]]]]" method="post">
        <fieldset>
             [[instruments]]
        </fieldset> 
    </form>
    



    The instruments snippet is like this:

    <?php
    $path = MODX_CORE_PATH . 'components/instruments/';
    $result = $modx->addPackage('instruments',$path . 'model/','users_');
    $profile = $modx->user->getOne('Profile');
    $extended = $profile->get('extended');
    $selectedInstrument = $extended['instrument'];
    
    
    if ($result) {
       $instruments = $modx->getCollection('Instruments'); 
       $output = '<select name="instrument" id="instrument"><option value="0">Les Instrument</option>';
    
       foreach($instruments as $instrument) {
               $in = $instrument->get('instru');
               ($in == $selectedInstrument) {
                    $selected = 'selected="selected"';
               }
               else{
                      $selected = "";
               }
        $output .= '<option '.$selected.' value="'. $instrument->get('instru') .'">'. $instrument->get('instru') .'</option>';
        
    }
    $output .= "</select>";
    } else {
      $output = "";
    }
    return $output;



    $selectedInstrument is not updated instantly with the value of extended instrument..

    what am i missing here? [ed. note: stevebravo last edited this post 11 years, 9 months ago.]
      • 37686
      • 94 Posts
      so.. when i change instrument in the dropdown to piano, the selected = selected does not apply, because selectedInstrument stills give me the previous value (like guitar), while the table is updated to piano though
        • 3749
        • 24,544 Posts
        Try calling the snippets uncached, like this:

        [[!UpdateProfile]]
        
        [[!Instruments]]



        ------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using.
        MODX info for everyone: http://bobsguides.com/modx.html
          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