<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dauidus Design &#187; Client Management</title>
	<atom:link href="http://www.dauidusdesign.com/category/web-design/wordpress/client-management/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dauidusdesign.com</link>
	<description>Web design, graphic design and professional photography from Dave Winter</description>
	<lastBuildDate>Wed, 30 Jan 2013 19:09:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Using WordPress as a Simple Client Management Solution</title>
		<link>http://www.dauidusdesign.com/using-wordpress-as-a-simple-client-management-solution/</link>
		<comments>http://www.dauidusdesign.com/using-wordpress-as-a-simple-client-management-solution/#comments</comments>
		<pubDate>Thu, 07 Oct 2010 01:57:44 +0000</pubDate>
		<dc:creator>Dave Winter</dc:creator>
				<category><![CDATA[Client Management]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[WordPress Plugin]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Freelancers]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.dauidusdesign.com/?p=802</guid>
		<description><![CDATA[So, you're looking to give your clients a secure way to access a client page (or group of pages) on your Wordpress powered site.  There's just one problem... there isn't a Wordpress plugin that can do it for you with out-of-the-box functionality that we've grown accustomed to.  But before you give up on client management (or Wordpress) altogether, let me assure you, it can be done.  So, if you're up for learning a new trick with some old programming knowledge and a little elbow grease, let's get started...]]></description>
				<content:encoded><![CDATA[<p><img class="blogtop" title="WordPress" src="http://www.dauidusdesign.com/wp-content/uploads/2010/08/login11.jpg" title="Using WordPress as a Simple Client Management Solution" alt="WordPress Client Management Made Easy" width="200" height="200" /></p>
<p>S<em>o, you&#8217;re looking to give your clients a secure way to access a client page (or group of pages) on your WordPress powered site.  There&#8217;s just one problem&#8230; there isn&#8217;t a simple WordPress plugin that can do it for you with the out-of-the-box functionality we&#8217;ve grown accustomed to.  But before you give up on client management (or WordPress) altogether, let me assure you, it can be done.  So, if you&#8217;re up for learning a new trick with some old programming knowledge and a little elbow grease, let&#8217;s get started.</p>
<p style="text-align: left;">Before we begin, have a look at this <a href="http://old.dauidusdesign.com/wp-login.php" >example client login page</a> from my old site to get an idea of our goal.<br />
Username:demo Password:client</p>
<p style="text-align: left;">This setup has been tested up to WP 3.1.2</p>
<p></em></p>
<h4 style="color: #0099cc;" >First Things First: The Plugins</h4>
<p style="text-align: left;">
<a href="http://www.im-web-gefunden.de/wordpress-plugins/role-manager/" >Role Manager</a><br />
This plugin is not directly available on WordPress.org, but makes for much less of a headache throughout the next steps.  To set it up correctly, go to users &#8211;> roles and add a new role named &#8216;client&#8217;.  Make sure to only enable the &#8216;read&#8217; function (otherwise, your clients may be able to access your dashboard or other administrative pages and change the content of your site.
</p>
<p style="text-align: left;">
<a href="http://wordpress.org/extend/plugins/iwg-hide-dashboard/" >IWG Hide Dashboard</a><br />
The main purpose of this plugin is to keep non-admin users out of admin only areas of your WordPress installation.  To enable this function, simply make sure the &#8216;hide dashboard&#8217; option is checked for the &#8216;client&#8217; role we created in the last step.
</p>
<p style="text-align: left;">
<a href="http://wordpress.org/extend/plugins/peters-login-redirect/" >Peter&#8217;s Login Redirect</a><br />
Really, this plugin is what makes simple client management possible.  It allows you to easily direct a logged in user to a specific page on your site that will serve as their customized client page.  It does this by checking the user&#8217;s role (that it integrates with the previous plugins) and sending the user to a pre-defined URL.
</p>
<h4 style="color: #0099cc;" >The Code</h4>
<p style="text-align: left;">There.  That wasn&#8217;t so bad, was it?  Well, we still have a ways to go&#8211; and it involves modifying some code.  Don&#8217;t worry, though.  I&#8217;ll try to make it as straight forward and painless as possible.</p>
<p style="text-align: left;">First, we have to add a login/logout form somewhere on our page.  Mine is located in the drop down menu at the very top of <del datetime="2010-12-12T11:02:21+00:00">this page</del> my old site, but you can easily place it anywhere in your theme.  The easiest is to add this to either your header or footer template pages, as they will (probably) require less maintenance and tweaking as your site evolves (many themes utilize more than one sidebar or main content template, whereas most stick with a common header and footer throughout).  Just paste the following code where you want the form to appear (files are found in the /wp-content/themes/your-theme-name folder on a standard WordPress installation).</p>
<pre class="brush: php; html-script: true; title: ; notranslate">
/* Login/Logout Forms */

&lt;?php if (!(current_user_can('level_0'))){ ?&gt;

    &lt;form action=&quot;&lt;?php echo get_option('home'); ?&gt;/wp-login.php&quot; method=&quot;post&quot;&gt;
        &lt;input type=&quot;text&quot; name=&quot;log&quot; id=&quot;log&quot; value=&quot;&lt;?php echo wp_specialchars(stripslashes($user_login), 1) ?&gt;&quot; size=&quot;20&quot; /&gt;
        &lt;input type=&quot;password&quot; name=&quot;pwd&quot; id=&quot;pwd&quot; size=&quot;20&quot; /&gt;
        &lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Login&quot; /&gt;

            &lt;p&gt;&lt;input type=&quot;hidden&quot; name=&quot;redirect_to&quot; value=&quot;&lt;?php echo $_SERVER['REQUEST_URI']; ?&gt;&quot; /&gt;&lt;/p&gt;
    &lt;/form&gt;

    &lt;a href=&quot;&lt;?php echo get_option('home'); ?&gt;/wp-login.php?action=lostpassword&quot;&gt;Forgot Password?&lt;/a&gt;



/* if a user is logged in, display username and logout button */

    &lt;?php } else { ?&gt;
        &lt;h3&gt;Logged In as:
            &lt;?php global $current_user; get_currentuserinfo(); echo ''. $current_user-&gt;user_login . &quot;&quot;; ?&gt;
        &lt;/h3&gt;

        &lt;a href=&quot;&lt;?php echo wp_logout_url(); ?&gt;&quot;&gt;Logout&lt;/a&gt;

&lt;?php }?&gt;

/* END */
</pre>
<p style="text-align: left;">Next, you&#8217;ll need to create a template for your clients&#8217; pages.  I have chosen to name mine &#8216;client.php&#8217;, based on the role I created earlier and overall ease of use.</p>
<p style="text-align: left;">Simply copy and paste this code into a text file and save it as &#8216;client.php&#8217;. Of course, be sure to change the styled XHTML to fit your theme.</p>
<pre class="brush: php; highlight: [5,14,18,21]; html-script: true; title: ; notranslate">
/* client.php */

&lt;?php
/*
Template Name: client 
*/
?&gt;

&lt;?php get_header(); ?&gt;

*/ display the logged in client's username and provide a logout button */

    &lt;div id=&quot;pageHeaderText&quot;&gt;
        &lt;?php while (have_posts()) : the_post(); ?&gt;
		&lt;?php $pagetitle = get_post_meta($post-&gt;ID, 'title', $single = true);

		if($pagetitle !== '') : ?&gt;
                    &lt;h2&gt;&lt;?php echo($pagetitle); ?&gt;&lt;/h2&gt;

                &lt;?php else : ?&gt;
                    &lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;/h2&gt;

                &lt;?php endif; ?&gt;

	&lt;?php endwhile; ?&gt;
    &lt;/div&gt;&lt;!-- end pageHeaderText --&gt;
*/ END */



&lt;div id=&quot;content&quot; class=&quot;full&quot;&gt;   /* this is part of my theme -- change accordingly */
	&lt;div id=&quot;center&quot;&gt;

*/ display the content of client's page */

        &lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
            &lt;div class=&quot;entry&quot;&gt;

                &lt;?php wp_link_pages(array('before' =&gt; '&lt;p&gt;&lt;strong&gt;Pages:&lt;/strong&gt; ', 'after' =&gt; '&lt;/p&gt;', 'next_or_number' =&gt; 'number')); ?&gt;

                &lt;?php the_content('&lt;p class=&quot;serif&quot;&gt;Read the rest of this page &amp;raquo;&lt;/p&gt;'); ?&gt;
            &lt;/div&gt;

        &lt;?php endwhile; endif; ?&gt;
*/ END */
            


	&lt;/div&gt;&lt;!-- end center --&gt;  
&lt;/div&gt;!-- end content --&gt;

    &lt;div class=&quot;clear&quot;&gt;&lt;div&gt;
    
&lt;?php get_footer(); ?&gt;

/* END */
</pre>
<p style="text-align: left;">Go ahead and upload everything (client.php and whatever file you amended the login form to) to your &#8216;/wp-content/themes/your-theme-name&#8217; folder and we&#8217;ll be off to our final steps.</p>
<h4 style="color: #0099cc;" >Setting Up: Configuring the Plugins</h4>
<p style="text-align: left;">Now that we&#8217;ve installed our plugins and set up our php code to allow for client login management, let&#8217;s go ahead and configure those plugins to function properly.  On your WordPress dashboard, open your &#8216;users&#8217; tab and select &#8216;add new&#8217;.  Create a new user called &#8216;demo&#8217; and give it the role of &#8216;client&#8217; (that we created earlier).  Enter your email where required and give your new user the password &#8216;client&#8217; (we&#8217;ll test using this username and password in just a bit).</p>
<p style="text-align: left;">Next, scroll down to where it says &#8216;assign extra capabilities&#8217; (if this is not present, make sure you correctly installed the &#8216;role manager&#8217; plugin above).  Make certain that only the fields &#8216;hide dashboard&#8217; and &#8216;read&#8217; are checked, then save your new user.</p>
<p style="text-align: left;">Now, on your dashboard, go to the settings tab and click on &#8216;Login redirects&#8217;.  Under &#8216;Specific Roles&#8217; make sure that administrator is checked and set the URL to &#8216;http://www.your-domain.com/wp-admin/index.php&#8217; (this will automatically direct all administrators to the dashboard on login).  Click &#8216;update&#8217;.</p>
<p style="text-align: left;">OK, here&#8217;s what we&#8217;ve been waiting for.  Under &#8216;Specific Roles&#8217; again, let&#8217;s add the role &#8216;client&#8217; (that we created earlier) and give it the URL &#8216;http://www.your-domain.com/[variable]username[/variable]&#8216;.  Save it.  This will, essentially, redirect all users with the role &#8216;client&#8217; to a page with the same name as the client&#8217;s username.  In other words, if the username is &#8216;demo&#8217;, the corresponding client page must be named &#8216;demo&#8217; and point to a URL ending in &#8216;/demo/&#8217;.  (To make client pages more manageable, you may want to redirect users to a sub-page in order to keep your pages list more controlled.  In this case, you would give the &#8216;client&#8217; role the URL &#8216;http://www.your-domain.com/clients/[variable]username[/variable]&#8216; if you would like all client pages to be sub-pages of the parent page &#8216;client&#8217;.  This is not necessary, but will make your life a whole lot easier when managing more than a few clients at a time.)</p>
<p style="text-align: left;">Congratulations!  You have successfully configured all the required plugins.  Just one thing left to do&#8230;</p>
<h4 style="color: #0099cc;" >The Final Step: Creating Client Pages</h4>
<p style="text-align: left;">Finally, after all that, we can go ahead and create our demo client page!  Let&#8217;s add a new page called &#8216;demo&#8217; (if seeking to make all client pages sub-pages, make &#8216;demo&#8217; a sub-page of the page &#8216;clients&#8217;, or whatever you want the parent page to be).  On the right side of your screen, in the tab &#8216;Page Attributes&#8217;, make sure the template field is set to &#8216;client&#8217; and a parent page is selected (if desired).  I have also chosen to make my client pages password protected to disallow any unauthorized access.  To do so, just assign the client&#8217;s user password to the page.</p>
<p style="text-align: left;">Make sure that your permalink matches what you set under &#8216;Specific Roles&#8217; above and you should be good to go.  Just fill in the page with some client information, sign out of your WordPress account, and use the login form we installed on your page to login with the username &#8216;demo&#8217; and password &#8216;client&#8217;.  You should be redirected right to the demo client page.  If it worked for you, simply add more client pages and pat yourself on the back.</p>
<p style="text-align: left;">
<p style="text-align: left;">If you have any questions or comments on this tutorial, leave me a comment to let me know.  Happy coding!</p>
<p style="text-align: left;">EDIT:</p>
<p style="text-align: left;">Thanks to the comment by the user &#8216;underscore&#8217; in the <a href="http://wordpress.org/support/topic/my-crack-at-a-client-login-sectioncustomer-portal" >WordPress.org Support Forums</a>, we now have an easy way to limit each user&#8217;s login to viewing only that user&#8217;s client page.  It does this by checking a user&#8217;s username against a client page&#8217;s title.  If the two are the same, the page is allowed to be viewed.  If they don&#8217;t match, the user is sent to your universal wp-login.php page.  Simply add the following code near the top of your client page&#8217;s template.  Be sure to edit the highlighted lines to reflect your site&#8217;s requirements and you should be good to go.</p>
<pre class="brush: php; highlight: [13,20,23]; html-script: true; title: ; notranslate">
/* insert into client.php */

&lt;?php 
    $username = ( $userdata-&gt;user_login ); 
?&gt;

    &lt;?php
        $url =  $_SERVER['REQUEST_URI'];
        $urlItemsArr = explode( '/', $url );

    /*

        print ('client/'.$userdata-&gt;user_nicename);
        print '&lt;br /&gt;';
        print ($urlItemsArr[1].'/'.$urlItemsArr[2] );
        print '&lt;br /&gt;';

    */

            if ( strcmp( 'client/'.$userdata-&gt;user_nicename, $urlItemsArr[1].'/'.$urlItemsArr[2] ) == 0) {
	       print 'Allowed';
            } else {
	       header('Location:http://www.your-URL.com/wp-login.php') ;
            }
    ?&gt;

/* END */
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.dauidusdesign.com/using-wordpress-as-a-simple-client-management-solution/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>
