• Resolved kpdesign

    (@kpdesign)


    I am trying to set up private pages for my clients – one page for each of them. The page structure is:

    Clients
    — Client 1
    — Client 2
    — Client 3

    I’ve already created the individual pages, and each one is marked “private”, as is the parent page “Clients”.

    I am using the Role Manager plugin (2.2.2) to manage the roles/capabilities. I’ve set up a role for each client, and a special capability for each one as well:

    Role: Client1
    Capabilities enabled: read and view_client1_hidden_pages
    Level: 0

    Role: Client2
    Capabilities enabled: read and view_client2_hidden_pages
    Level: 0

    Role: Client3
    Capabilities enabled: read and view_client3_hidden_pages
    Level: 0

    I created another custom capability for myself – view_all_hidden_pages – so that I can have a list of links to all of the client private pages in my sidebar. That works fine – I see the links and can view all of the private pages.

    In my sidebar, I’ve also set up a Control Panel block, which includes a login form (which is working fine), and once logged in, a list of their links:

    Your Account Summary
    Edit Profile
    Logout

    I’m using the following code to pull in the links for each client:

    <?php global $user_identity ?>
    
    <?php if (is_user_logged_in()){ ?>
    
    <!-- If user logged in, display their links -->
    <h4>Control Panel</h4>
    
    <ul class="login">
    <li>Welcome back <strong><?php echo $user_identity ?></strong></li>
    <?php if (current_user_can('view_client1_hidden_pages')){ ?>
    <li><a href="<?php bloginfo('url') ?>/clients/client1/" title="Your Account Summary">Your Account Summary</a></li>
    <?php } ?>
    <?php if (current_user_can('view_client2_hidden_pages')){ ?>
    <li><a href="<?php bloginfo('url') ?>/clients/client2/" title="Your Account Summary">Your Account Summary</a></li>
    <?php } ?>
    <?php if (current_user_can('view_client3_hidden_pages')){ ?>
    <li><a href="<?php bloginfo('url') ?>/clients/client3/" title="Your Account Summary">Your Account Summary</a></li>
    <?php } ?>
    <li><a href="<?php bloginfo('url') ?>/wp-admin/profile.php" title="Edit profile">Edit profile</a></li>
    <li><a href="<?php bloginfo('url') ?>/wp-login.php?action=logout&amp;redirect_to=<?php echo urlencode($_SERVER['REQUEST_URI']) ?>" title="Log out">Log out</a></li>
    </ul>
    
    <?php } else { ?>
    
    <!-- If user not logged in, display the login form -->
    <h4>Client Login</h4>
    
    <div>
    <form action="<?php bloginfo('siteurl'); ?>/wp-login.php" method="post" id="loginform">
    ---------(login form and lost password code)--------
    </form>
    </div>
    <?php } ?>

    The links are showing up just fine for each client – once logged in, they only see their individual link in the sidebar, along with Edit Profile and Logout. However, when they click that link, it brings up the ‘404-Not Found’ page, not their private page.

    If I enable read_private_pages for one of the roles, they are then able to click their link and view their page, but they can also see the private pages for each of the other clients, which I don’t want.

    I’ve researched this issue on the forum, the Codex, and the Role Manager plugin homepage, and am unable to come up with a solution. There has to be a setting that I’m overlooking somewhere, but I’ve racked my brain and can’t figure this out. Perhaps a fresh set of eyes can point out what I’m missing.

    Any help/pointers to find the solution will be most appreciated. ??

Viewing 1 replies (of 1 total)
  • Thread Starter kpdesign

    (@kpdesign)

    I finally resolved this issue. I removed the Role Manager plugin after finding another one (wpNamedUsers) that did what I needed without having to create a special role for each client.

    I’ve written an article on how I accomplished this, and am linking it here in case anyone else has the same issue and wants to know the solution.

Viewing 1 replies (of 1 total)
  • The topic ‘404 error on private pages’ is closed to new replies.