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 form and 2 redirect landing pages - so I need a custom redirect hook to read the values from the formit form, and throw the user to the relevant redirectto page based on the values of the form. Any chance of a PHP clue on how to achieve this?

    So... for example, in the form, I have an input with name="failornot" - then in the hook, if field "failornot" == "fail", then redirect to page "1", or if field "failornot" == "pass", then redirect to page "2"

    Is this possible? Been looking at redirect paramaters - and then using jquery to look at the url and show/hide content on the same page but I dont like that approach...

    Any ideas?

    Cheers

    dubbs.

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

    • discuss.answer
      • 8168
      • 1,118 Posts
      OK - worked this out - for those interested code example below:

      $failornot = $hook->getValue('failornot');
      
      if ( $failornot == "fail" ) {
      $url = $modx->makeUrl(1);
      $modx->sendRedirect($url);
      }
      
      if ( $failornot == "pass" ) {
      $url = $modx->makeUrl(2);
      $modx->sendRedirect($url);
      }
      
      
      return true;