How to redirect every login page to my custom login page

Hello Sir,
I have made a custom login page http://aureusart.com/login/

Now what is my problem,when clicking to "Login/signup",it redirect to my custom login page.its fine.
When clicking to "Sell art",it does not redirect to my custom login page instead it redirects to wordpress login page. This page I have restricted.

I want that every login page should be my custom login page.

Now next question:
When I login with my superadmin login details,it directly redirect to the superadmin dashboard.
But when login with subsite user details,it redirect to another page saying that "View dashboard or view site".
I want that it should directly redirect to home page likewise superadmin.

Please let me know

Thanks

  • Ash

    Hello @Priti

    I hope you are well today and thanks for asking the question.

    Please use the following code to redirect the wp-login.php to your custom login page:

    add_action('init','possibly_redirect');
    
    function possibly_redirect(){
     global $pagenow;
     if( 'wp-login.php' == $pagenow ) {
      wp_redirect('YOUR CUSTOM PAGE URL');
      exit();
     }
    }

    To redirect the user to his primary blog, use the following:

    function go_to_primary_blog($redirect_to, $request, $user){
    	$user_info = get_userdata($user->ID);
    	return get_blogaddress_by_id($user_info->primary_blog) . 'wp-admin';
    }
    add_filter("login_redirect", "go_to_primary_blog", 10, 3);

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

  • Ash

    Hello @Priti

    I hope you are well today.

    Would you please send me login details and FTP details?

    To send me details, please use our contact form: https://premium.wpmudev.org/contact/

    Select: I have a different question
    Subject: Attn-Ash (this ensures that it will be assigned to me)
    Details:
    1. Send all requested details
    2. Send a link of this thread so that I can track
    3. Send any other relevant link

    I will be happy to take a look :slight_smile:

    Cheers
    Ash

  • Ash

    Hello @Priti

    I hope you are well today.

    I have added the correct code, please check now.

    function possibly_redirect(){
      global $pagenow;
      if( 'wp-login.php' == $pagenow ) {
        if ( isset( $_POST['wp-submit'] ) ||   // in case of LOGIN
          ( isset($_GET['action']) && $_GET['action']=='logout') ||   // in case of LOGOUT
          ( isset($_GET['checkemail']) && $_GET['checkemail']=='confirm') ||   // in case of LOST PASSWORD
          ( isset($_GET['checkemail']) && $_GET['checkemail']=='registered') ) return;    // in case of REGISTER
        else wp_redirect('http://aureusart.com/login/'); // or wp_redirect(home_url('/login'));
        exit();
      }
    }
    add_action('init','possibly_redirect');

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.