WordPress and buddypress programming

Redirect Users to the Custom Registration and Login Page

Viewing 1 reply thread
  • Author
    Posts
    • #1476
      michael mc
      Keymaster
      @michael

      Registration Page Redirection

      Note: Replace /registration-url in the code below with the new URL of your custom registration page.
      #wordpress

      // Redirect Registration Page
      function my_registration_page_redirect()
      {
          global $pagenow;
       
          if ( ( strtolower($pagenow) == 'wp-login.php') && ( strtolower( $_GET['action']) == 'register' ) ) {
              wp_redirect( home_url('/registration-url'));
          }
      }
       
      add_filter( 'init', 'my_registration_page_redirect' );
    • #1477
      michael mc
      Keymaster
      @michael

      Login Page Redirection

      Note: Replace /login-url in the code below with the new URL of your custom login page.

      function my_redirect_login_page() {
      $login_page = home_url( '/login-url' );
      $page_viewed = basename($_SERVER['REQUEST_URI']);
       
      if( $page_viewed == "wp-login.php" && $_SERVER['REQUEST_METHOD'] == 'GET') {
      wp_redirect($login_page);
      exit;
      }
      }
      add_action('init','my_redirect_login_page');
Viewing 1 reply thread
  • You must be logged in to reply to this topic.