redirect again

Discussion in 'Customization & add-ons' started by deltoro, May 19, 2017.

  1. deltoro

    deltoro New Member

    Joined:
    Jan 16, 2017
    Messages:
    3
    Hi,

    I have a custom field for my aMember user record and would like to redirect the user depending on the value of this field.

    This should happen after the user logged in using the aMember widget (if($api->isLoggedIn())):

    Something like:
    if value == a then redirect to url_a else redirect to url_b

    Thanks!
  2. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,659
    Hello,

    Here is example of code that you can use in site.php:
    http://www.amember.com/docs/Site.php_file

    PHP:
    Am_Di::getInstance()->hook->add(Am_Event::AUTH_GET_OK_REDIRECT, function(Am_Event $e) {
       
        
    $user $e->getUser();
        switch(
    $user->fieldname) {
            case 
    'a' :
                
    $e->setReturn('/redirect/url/a');
                break;
            case 
    'b' :
                
    $e->setReturn('/redirect/url/b');
                break;
            case 
    'c' :
                
    $e->setReturn('/redirect/url/c');
                break;
        }
       
    });
    Reference:
    http://www.amember.com/docs/API/HookManager

Share This Page