We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8168
    • 1,118 Posts
    Hi guys,

    I have a formit form and a post hook which sends out a few emails, sets a TV value and performs a redirect....

    I am having an issue with the TV setting and redirect whereby - I cant get both to work, I can get it so that either one of theses processses works, but not working together...

    Code is:

    // Get parent page title
    $parentObj1 = $modx->resource->getOne('Parent');
    $parentpageid1 = $parentObj1->get('id');
    
    $doc = $modx->getObject('modDocument',$parentpageid1);
    $newValue = "YES";
    $doc->setTVValue(30, $newValue);
    
    
    // redirect
    $url = $modx->makeUrl(12);
    $modx->sendRedirect($url);
    return true;
    


    In the code example above, the redirect works, but the TV value is not set.. If I move the "return true;" to sit below the TV setting code, then that works, but the redirect doesn't... Any ideas on how to make it so that both work??

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

    • discuss.answer
      • 8168
      • 1,118 Posts
      Easiest way to resolve this was to call both bits in 2 different hooks... works then! Odd!
        • 3749
        • 24,544 Posts
        I'd suggest this change. It will make the redirect more reliable:

        $url = $modx->makeUrl(12, "", "", "full");
          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
          • 8168
          • 1,118 Posts
          Quote from: BobRay at Aug 31, 2016, 01:44 PM
          I'd suggest this change. It will make the redirect more reliable:

          $url = $modx->makeUrl(12, "", "", "full");

          Thanks Bob