How to redirect user to different thanks page after payment

Discussion in 'aMember Pro v.4' started by fmagusto, Apr 7, 2013.

  1. fmagusto

    fmagusto Guest

    Is possible to use
    <?php
    Am_Di::getInstance()->hook->add(Am_Event::THANKS_PAGE, 'onThanksPage');
    function onThanksPage(Am_Event $event){
    $di = Am_Di::getInstance();
    Am_Controller::redirectLocation('/url/where/user/should/be/redirected');
    }
    ?>

    For product 1
    Am_Controller::redirectLocation('/url/where/user/should/be/redirected');
    Product 2
    Am_Controller::redirectLocation('/url/where/user/should/be/other');

    Etc.
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Sure possible.
    PHP:
    $invoice $event->getInvoice();
    $products $invoice->getProducts();
    $product $products[0];
    if(
    $product->pk()==1)
       
    Am_Controller::redirectLocation('/url/where/user/should/be/redirected');
    if(
    $product->pk()==2)
      
    Am_Controller::redirectLocation('/url/where/user/should/be/other');

  3. fmagusto

    fmagusto Guest

    Yes :) Thank Alexander
    I add this in site.php ?
  4. hilary

    hilary aMember Pro Customer

    Joined:
    Aug 22, 2006
    Messages:
    104
    Alexander, could you post the complete code for this ready to copy and paste? Thanks!
  5. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Of course.
    Unzip & Upload attached file to amember/application/default/plugins/misc/ folder
    enable plugin at aMember CP -> Setup -> Plugins : Misc

    Then you have new field in product settings: Thanks Page URL

    Attached Files:

    hilary likes this.
  6. fmagusto

    fmagusto Guest

    Hi Alex.
    I have this error
    <b>WARNING:</b> Error loading plugin [thanks-redirect-1]: Error in plugin misc/thanks-redirect-1: class [Am_Plugin_ThanksRedirect1] does not exists! in line 115 of file /home/infoconc/www/amember/library/Am/App.php


    trigger_error [ library/Am/App.php : 115 ]
    Am_Plugins->getAllEnabled [ library/Am/App.php : 1695 ]
    Am_App->initHooks [ library/Am/License.php(19) : eval()'d code(1) : eval()'d code : 100 ]
    Am_License->init [ library/Am/App.php : 1661 ]
    Am_App->initFront [ library/Am/App.php : 1371 ]
    Am_App->bootstrap [ bootstrap.php : 25 ]
    require_once [ index.php : 42 ]
  7. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    You get this error because you have modified plugin code . There is no Am_Plugin_ThanksRedirect1 inside original file.
  8. mihkel

    mihkel New Member

    Joined:
    Jun 23, 2012
    Messages:
    20
    Super! Thanks!
  9. mihkel

    mihkel New Member

    Joined:
    Jun 23, 2012
    Messages:
    20
    hei,
    how insert next row, how redirect user to different page after login? :)

    Mihkel
  10. mihkel

    mihkel New Member

    Joined:
    Jun 23, 2012
    Messages:
    20
    new field : Login Page URL , is it possible?
  11. fmagusto

    fmagusto Guest

    Thank Alex. Verry good job :)

Share This Page