geminilabs

Customise the WordPress login url

Dec 14th, 2018
655
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. /**
  2.  * Customize the login URL of your website
  3.  * Paste this into your active theme's function.php file
  4.  * @param string $login_url
  5.  * @param string $redirect
  6.  * @return string
  7.  */
  8. add_filter( 'login_url', function( $login_url, $redirect ) {
  9.     if( is_admin() ) {
  10.         return $login_url;
  11.     }
  12.     // Change this to your own login URL path
  13.     $custom_login_path = 'custom-login-page';
  14.     $login_url = site_url( $custom_login_path, 'login' );
  15.     if( !empty( $redirect )) {
  16.         $login_url = add_query_arg( 'redirect_to', urlencode( $redirect ), $login_url );
  17.     }
  18.     return $login_url;
  19. }, 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment