• CLIENT PORTAL / CLIENT ACCESS PAGE
    I am trying to build a wp site for a company that wants their clients to be able to login and see a restricted-access, personalized page of content, links, downloads, etc. Simple enough in the real world, but quite a challenge in wp, for a newbie anyway.

    I just spent the better part of the day (and night) trying to figure this out, searching the forums, google, codex, plugins.. but couldn’t find exactly what I was looking for. Some plugins were way too complex and confusing, some too limited. Well I finally did come up with something that works for me, so I wanted to share it in case it helps anyone else. Here’s what I did:

    PLUGIN — Members
    (By Justin Tadlock)
    – create a new Role called “Client” with just “read” capability.

    PLUGIN — Peter’s Login Redirect
    (By Peter)
    – in “specific roles” section, set redirect url for my “Client” role to “client-portal”.

    USERS
    – create a User for each client.
    – set his Role to “Client”.

    CLIENT PORTAL
    – create a Client Portal page, with same url as the redirect (“client-portal”), where ALL clients will land.
    – create and apply a custom page Template (in your theme) that has:
    <?php
    global $current_user;
    get_currentuserinfo();
    $page = get_page_by_title($current_user->user_login);
    _e($page->post_content);
    ?>

    INDIVIDUAL CLIENT PAGE/CONTENT
    . create a child page (with Client Portal as parent) for each Client.
    . set Visibility: Private, so it’s never displayed to anyone by url.
    . Title must match the client’s Username!!!!
    . Write the content, links to downloadable files, personalized messages, etc.

    That’s it.
    I think.

Viewing 15 replies - 1 through 15 (of 20 total)
  • Thanks! This has been very helpful!
    Am new to WordPress … could you give some more detailed instructions and how to create and apply a custom page template (in the theme).

    Shane

    Thanks for posting this – it just helped me a lot, and saved me a large amount of time doing research.

    Thread Starter htz77

    (@tzeldin88)

    @shanelh – I’m fairly new at WP myself, and I have not yet actually implemented this strategy yet on a site, but i did prove the concept to myself and still plan to use it. I’d be happy to give more detail if you still need it, but what specific part do you need help on? For the Custom Page Template: the idea is that you need to add that chunk of PHP code…

    global $current_user;
    get_currentuserinfo();
    $page = get_page_by_title($current_user->user_login);
    _e($page->post_content);

    only on your “client-portal” page, so:
    – i basically just made a copy of my normal page.php, saving it as “client-portal.php”.
    – in the comments at the very top, i added “Template Name: ClientPortal” (so wp admin is aware of this new template).
    – added that code just before “the loop” [the “if (have_posts())…” section ].
    – in wp admin, create a page “Client Portal” to act as the Parent to all the client pages.
    – in wp admin, create a page “JoeSmith” (whatever your client’s WP username is… this is VITAL), and in the sidebar, for the Template dropdown, choose your new ClientPortal template. i also set the Parent dropdown to the “Client Portal” page, just for proper nesting.

    hope this helps.

    I am imagining that this would be easy if instead of adding the users manually I can just configure it to give people access when they create a user account.

    I don’t really want to make it totally private, but at least have the person sign-up with a username before accessing some documents that I am going to host on the landing page.

    Would I be correct in my assumption?

    Thanks for the great post.

    Just went through and set this up – tzeldin88 your post is very appreciated. I thought I’d go ahead and toss the links to the plugins you list.

    Members: https://www.ads-software.com/extend/plugins/members/
    Peter’s Login Redirect: https://www.ads-software.com/extend/plugins/peters-login-redirect/

    I’d love to check out your website if you wouldn’t mind posting it.

    I am researching creating a private area on a wordpress site.

    I’m also interested in making a more custom registration form beyond the default one. I’ve been looking into Registration Plus, but I have been reading that it is very unstable and other options look thin.

    You all have been very helpful spelling this out. I just can’t seem to get the code in correctly? This is my client-portal.php code. Am I doing something wrong?

    [Code moderated as per the Forum Rules. Please use the pastebin]

    This looks great, exactly what I needed it seems.

    Has anyone tried or done interfacing this with some photo/video gallery plugin or theme, so each client would have their own (private) photo+video gallery (from self-hosted files)?

    ==EDIT==

    I (believe I) followed the above instructions, and right now, upon login, my test client is redirected to the Client Portal page (parent). Is there a way I could have each client redirected to their own (child) page? Or am I missing something?

    TIA.

    Thread Starter htz77

    (@tzeldin88)

    @adbl — I haven’t tried this with a photo gallery. Also: the logged-in client will be redirected to the client-portal page (url), but that page should actually display the post of the child page. It gets the client’s Username and uses that *exact* value to find a page with a matching Title. If you’re not seeing the content of the child page, you might not have perfectly matching Username and Title.

    that worked really great, thanks! One problem though:

    When nobody is logged in in the client-portal area the number “2”is shown. The PHP code seems to generate the intended function but also this sweet little lonely “2”…. Any idea how to stop this?

    Cheers,
    Thomas

    Not sure why, but no matter what I did, the child content was displaying on the parent “portal” page. But only if the client was logged in. Also the content was displaying all the way above the <link> elements of the head of my document.

    So I removed

    _e($page->post_content);

    to solve that problem.

    Well I guess that just breaks everything… bah!

    Has anyone got this working properly yet?

    I followed all the instructions and it works but with a few minor problems:

    1. There is no login box on the Client-portal page so that the client has to find the login link elsewhere on the page (on my current theme the login link is very subtle and is located in the footer).

    – Is there a way of adding a box for username and one for password on the client page so that it is easier for the client to log in?

    2. Once logged in, the content on the client’s page is ADDED to the client-portal page instead of replacing it. So even after logging in the client sees the text from the previous client-portal page on their own client page.

    – Is there a way to make the client page completely replace the client-portal page instead?

    Thanks.

    UPDATE:

    I have managed to solve the first point by viewing the source of the default WordPress login page and copying and pasting the code into my client-portal page.

    This gave me the username and password boxes to enable the client to login.

    However, I am still stuck with the problem I described in my second point. This will confuse the client – after successfully logging in they are presented again with the login boxes even though the contents of their client page is added below.

    If I could get rid of those login boxes after the client has logged in it will be perfect.

    Anyone know how to do this?

    I have solved the problem I was experiencing. Here is the solution for those of you who might also be struggling with the same problems:

    Discard the client-portal template. It is what causes the problems and is unnecessary.

    In the Roles section tick the box that will allow clients to see private pages (read_private_pages).

    Use the login direct settings (‘Specific Users’ section) to redirect the user to the user’s page.

    That’s it!

    It’s simple and it works and will take a few minutes to set up with no hacking of any code required.

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘How-to: A simple Client Portal’ is closed to new replies.