- Install plugin – Members
- Create new role called ‘Client’ with only ‘read’ & ‘read_private_pages’ capability – you will see this option under the user section
- Install plugin – Peter’s Login Redirect
- In “specific roles” section, set redirect url for my “client” role to “client-portal” – you will find this in settings section ‘login/logout redirect’
- Create client users – set role to client
- Create a client-area template with templated code ( i have used the following code for flatpack theme)
<?php
/*
Template Name: ClientArea
*/
get_header(); ?><?php get_template_part(‘/functions/page-title’); ?>
<div id=”crumbs-container”>
<?php //ocmx_breadcrumbs(); ?>
</div>
<div id=”content”>
<div id=”left-column”>
<ul>
<?php
global $current_user;
get_currentuserinfo();
$page = get_page_by_title($current_user->user_login);
_e($page->post_content);if (have_posts()) :
while (have_posts()) : the_post(); setup_postdata($post);
get_template_part(“/functions/post-view”);
endwhile;
else :
ocmx_no_posts();
endif; ?></ul>
<?php if(comments_open()) {comments_template();} ?>
</div><?php if(get_option(“ocmx_sidebar_layout”) != “sidebarnone”): ?>
<?php //get_sidebar(); ?>
<?php endif;?></div>
<?php get_footer(); ?>
7. Add new page for the client-portal with template as ‘ClientArea’ with following code
<div id=”login”>
<form name=”loginform” id=”loginform” action=”http://websiteurl/wp-login.php” method=”post”>
<p>
<label for=”user_login”>Username<br>
<input type=”text” name=”log” id=”user_login” class=”input” value=”” size=”20″></label>
</p>
<p>
<label for=”user_pass”>Password<br>
<input type=”password” name=”pwd” id=”user_pass” class=”input” value=”” size=”20″></label>
</p>
<p class=”forgetmenot”><label for=”rememberme”><input name=”rememberme” type=”checkbox” id=”rememberme” value=”forever”> Remember Me</label></p>
<p class=”submit”>
<input type=”submit” name=”wp-submit” id=”wp-submit” class=”button button-primary button-large” value=”Log In”>
<input type=”hidden” name=”redirect_to” value=”http://websiteurl/client-area/”>
<input type=”hidden” name=”testcookie” value=”1″>
</p>
</form><p id=”nav”>
<a href=”http://websiteurl/wp-login.php?action=lostpassword” title=”Password Lost and Found”>Lost your password?</a>
</p><script type=”text/javascript”>
function wp_attempt_focus(){
setTimeout( function(){ try{
d = document.getElementById(‘user_login’);
d.focus();
d.select();
} catch(e){}
}, 200);
}wp_attempt_focus();
if(typeof wpOnload==’function’)wpOnload();
</script><p id=”backtoblog”><a href=”http://websiteurl” title=”Are you lost?”>← Back to Home Page</a></p>
</div>
8. Add specific client pages with parent as ‘client-area’ & template as ‘clientArea’
9. Go to settings-> login/logout redirect
10. Add specific users for each client page
11. Test logging in- if successful its done else go through the steps again & see what’s gone wrong
Creating login/logout link:
- Install plugin BAW Login|Logout
- Go to appearance -> menus, you should see the login/logout link option. Add it to your main menu
- if you have a custom login page. Modify the frontend-noajax.inc.php source code
Original:
$item->url = is_user_logged_in() ? wp_logout_url( $item_redirect[1] ) : wp_login_url( $item_redirect[0] );
Modified:
$item->url = is_user_logged_in() ? wp_logout_url( $item_redirect[1] ) :site_url( ‘index.php/client-area/’, ‘login’ );
4. you can modify the logout page in the same way.
Removing the wordpress admin header:
Go to your profile untick the show tool bar on viewing the site.