Last active
          November 19, 2020 08:57 
        
      - 
      
- 
        Save max-kk/d62ea6f15e3deaa77a69366fb6ca561d to your computer and use it in GitHub Desktop. 
    LRM :: filter redirect URL
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| // COPY AFTER to your theme functions.php | |
| add_filter('lrm/redirect_url', function($redirect_to, $action) { | |
| if ( 'login' !== $action ) { | |
| return $redirect_to; | |
| } | |
| // Do Something with a $redirect_to, like | |
| $url = parse_url( $_SERVER["HTTP_REFERER"] ); | |
| // CHANGE /log-in/ and /me/ to your values | |
| if ( $url['path'] === "/log-in/" ) { | |
| $redirect_to = "/me/"; | |
| } | |
| return $redirect_to; | |
| }, 11, 2); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| // COPY AFTER to your theme functions.php | |
| add_filter('lrm/redirect_url', function($redirect_to, $action, $user_id) { | |
| if ( 'registration' !== $action ) { | |
| return $redirect_to; | |
| } | |
| $user = get_userdata($user_id); | |
| if ( !in_array("customer", (array) $user->roles) ) { | |
| return "https://site.com/CUSTOMER/"; | |
| } | |
| return $redirect_to; | |
| }, 11, 3); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment