How to make custom client Login page for a specific page

I want to make client login form on the home page and when client login, I want the client to land into to specific page. Unless logged in, if tried to land to that page must be redirected to home page.

I have tried to use, Theme my login but did not get desired solution. I have tried to create my own widget area, and by password protecting the page. There are few problems that I faced.

Read More
  1. How to take user input and sanitaize it, I tried to use, wordpress esc_attr, esc_js, esc_html method, [Is that sufficient]
    1. I redirected the page to password protected page, but the password did not trigger the login.
    2. once I login to password protected page, it does not seem to log out even if I clear the cache or cookies.

So, basically, I want to have the solution. Thanks

Related posts

2 comments

  1. Here is a great article that explains one solution to do what you are trying to do that I’ve personally used. http://justintadlock.com/archives/2012/10/16/how-i-run-a-membership-site

    In your case you’ll want to customize the th3_club_member_template function to something like this:

    add_filter( 'template_redirect', 'nifty_log_in_check', 99 );
    
    function nifty_log_in_check( $template ) {
    
        if ( is_page('clients_only' ) ) && !current_user_can( 'view_client_content' ) ) //change this to suite your needs 
        {
            wp_redirect( home_url() );
            exit();
        }
    }
    

    You can then use theme my login to set up the login form.

    Once the user logs in you can either manually redirect them or use a plugin like Peters Login Redirect

    To manually redirect them you can do something like this:

    function nifty_login_redirect( $redirect_to, $request, $user ){
        //is there a user to check?
        global $user;
        if( isset( $user->roles ) && is_array( $user->roles ) ) {
            //check for admins
            if( in_array( "administrator", $user->roles ) ) {
                // redirect them to the default place
                return $redirect_to;
            } else {
                return home_url().'/client-area'; //change this
            }
        }
        else {
            return $redirect_to;
        }
    }
    add_filter("login_redirect", "nifty_login_redirect", 10, 3);
    

    [Codex]

  2. Our company uses WP-Client which is a plugin that allows to create client portals… you can make one for each individual client and control what they see when they login.

    You can customize the login page even… it’s been pretty easy to setup and the support is really good.

    Here is the website: http://wp-client.com

Comments are closed.