WordPress.org

Ready to get started?Download WordPress

Forums

How-to: A simple Client Portal (21 posts)

  1. tzeldin88
    Member
    Posted 4 years ago #

    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.

  2. shanelh
    Member
    Posted 4 years ago #

    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

  3. Will White
    Member
    Posted 4 years ago #

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

  4. tzeldin88
    Member
    Posted 4 years ago #

    @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.

  5. Working-Together
    Member
    Posted 4 years ago #

    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.

  6. Will White
    Member
    Posted 4 years ago #

    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: http://wordpress.org/extend/plugins/members/
    Peter's Login Redirect: http://wordpress.org/extend/plugins/peters-login-redirect/

  7. Working-Together
    Member
    Posted 4 years ago #

    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.

  8. tania.mayer
    Member
    Posted 4 years ago #

    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]

  9. ADBL
    Member
    Posted 4 years ago #

    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.

  10. tzeldin88
    Member
    Posted 3 years ago #

    @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.

  11. stl99
    Member
    Posted 3 years ago #

    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

  12. nickgassmann
    Member
    Posted 3 years ago #

    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.

  13. nickgassmann
    Member
    Posted 3 years ago #

    Well I guess that just breaks everything... bah!

  14. Dave333
    Member
    Posted 3 years ago #

    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.

  15. Dave333
    Member
    Posted 3 years ago #

    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?

  16. Dave333
    Member
    Posted 3 years ago #

    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.

  17. dtmp
    Member
    Posted 3 years ago #

    For those interested, this is very similar to a method suggested by JTWilcox here:
    http://wordpress.org/support/topic/my-crack-at-a-client-login-sectioncustomer-portal?replies=15

    It would be nice if someone could build a plugin to do all this.

  18. jakethebear
    Member
    Posted 3 years ago #

    @tzeldin88 just wanted to say thanks sooo much for this! used this method to build a client portal for a recent site and it does EXACTLY what it says on the tin... couldn't have been a more perfect solution. Will be using this exact technique again and again for sure. Kudos!

  19. Big AAC
    Member
    Posted 3 years ago #

    @Dave333 i'm not sure that works as all clients can then still see everyone elses private pages (not just there own private page) when logged in?!

    @tzeldin88 i've followed your instructions but i'm not sure where to lace the template php file, what do i callit? do i just place it in the theme folder? do i have to change any other code to point to it?

    any help your would great, thanks

  20. dtmp
    Member
    Posted 3 years ago #

    Here's another method I discovered to add to the list of options, this one uses S2member plugin: (bonus: there's even a video tutorial on how to set it up!)
    It appears to be a lot easier than these methods and provides page protection.

    http://www.primothemes.com/forums/viewtopic.php?f=4&t=586

  21. simo2010
    Member
    Posted 3 years ago #

    @Big AAC

    if you set in the page role: administrator and user, This page is only visible to these two!

Topic Closed

This topic has been closed to new replies.

About this Topic