Advertisement
phpface

Redirecting to custom url after logged in

Nov 12th, 2017
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. if( ! function_exists( 'videotube_login_redirect' ) ){
  2.     /**
  3.      *
  4.      * @param url $redirect_to
  5.      * @param unknown $request
  6.      * @param object $user
  7.      * @return url
  8.      */
  9.     function videotube_login_redirect( $redirect_to, $request, $user ) {
  10.         if( isset( $user->ID ) ){
  11.             $redirect_to = get_author_posts_url( $user->ID );
  12.         }
  13.         return $redirect_to;
  14.     }
  15.    
  16.     add_filter( 'login_redirect', 'videotube_login_redirect', 10, 3 ); 
  17. }
  18.  
  19. if( ! function_exists( 'videotube_logged_redirect_to' ) ){
  20.     /**
  21.      * @param url $redirect_to
  22.      * @param object $user
  23.      * @param array $data
  24.      * @return url
  25.      */
  26.     function videotube_logged_redirect_to( $redirect_to, $user , $data ) {
  27.         return get_author_posts_url( $user->ID );
  28.     }
  29.    
  30.     add_filter( 'vt_logged_redirect_to', 'videotube_logged_redirect_to', 10, 3 );
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement