Sales people's own personal read-only page

27 views
Skip to first unread message

Bill Woodland

unread,
Apr 12, 2012, 12:36:36 PM4/12/12
to wordpres...@googlegroups.com
Yep. I just got hit with this yesterday.

My client has developed a WordPress site with links to information
relevant to all of their sales people. Good for them so far. Here's
where I have to become their genius:

They want a place for sales people to log in to gain access to their own
personal "dashboard" of sorts (not like the WP dashboard). They would
have read only rights to the entire site, even their own dashboard, and
no rights at all to anyone else's dashboard. No page or post creation,
and the contents of their own dashboard would be built dynamically based
on what files are there for them to view/download (sales reports,
commission statements, etc.) and links to sales presentations only for
clients in their sales region. They could also have multiple sales regions.

I'm thinking that a modified shopping cart plugin might work for this:

No "shopping" until they log in
Their dashboard is their personal shopping cart
No shopping, no removal of items from their cart, and obviously, no
checkout/payment
The items in the cart are their reports, and links to their sales
presentations.
Items would be dynamically added to their cart, preferably in real time,
but a separate chron job would work, too.
Passwords would have to pass certain strictness codes (8 to 15 chars,
number letter combinations)

I'm just beginning to get back into WordPress, and haven't yet learned
enough to know if any built-in features might do the job. Is my
shopping cart idea more complex than necessary for my needs? Are any of
you aware of any other plugin that would be simpler?

I would appreciate any suggestions.


--

Bill Woodland, Austin, Tx squ...@austin.rr.com

treycarrico

unread,
Apr 12, 2012, 2:51:52 PM4/12/12
to wordpres...@googlegroups.com
It seems like you are trying to display custom dashboards from a CRM.  I am very interested in dash boards and integration of WordPress with
forms to crms
crms to customizable dashboards for all members of a company (ie. recievables, payables, sales, ceo, cto, etc)

I would be open to a focus group. 

Trey Carrico
talktotrey at gmail.com

Bill Woodland

unread,
Apr 12, 2012, 6:18:51 PM4/12/12
to wordpres...@googlegroups.com
I know the subject looks like an oxymoron: personal page that's
read-only? Not really as complex as a CRM, really, just one page for
each agent to access their own reports. The other back end code to
modify their pages would be a completely separate process.

Bobbie Wilson

unread,
Apr 13, 2012, 1:53:21 AM4/13/12
to wordpres...@googlegroups.com
Bill,

You can do this with a plugin and a new page template.

Create a new page template and upload it to your theme. I imagine the page template is where you want to call includes or ajax to show reports and things. In the WordPress dashboard, create a new page using this template. Note the permalink url when you publish it.
Install  Peter's Login Redirect plugin: http://wordpress.org/extend/plugins/peters-login-redirect/. This allows you to redirect after login based on roles. If you set the sales people to be subscribers, they won't be able to edit the page. In the settings for the plugin, add a new rule under the Select Roles title, using the permalink's page url (just mypage_name, not http://www.mysite.com/mypage_name).

To test that this was working, I added this snippet to the page template (above the loop) to display the current logged in user's name:
<code>
<?php global $current_user;
get_currentuserinfo();
?>
<p><?php echo $current_user->display_name; ?>'s page</p>
</code>

You can see the changes I made in action here:

Login with test_redirect/test_this

Hope this helps,
Bobbie



--
You received this message because you are subscribed to the Google Groups "WordPress Austin" group.
To post to this group, send email to wordpress-austin@googlegroups.com
To unsubscribe from this group, send email to wordpress-austin-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/wordpress-austin?hl=en

Our meeting information is available at http://www.meetup.com/austinwordpress/

Bill Woodland

unread,
Apr 13, 2012, 2:14:27 AM4/13/12
to wordpres...@googlegroups.com
Thank you, Bobbie. Interesting idea. At least it's a start (I'm a bit
clueless at the moment). I'll look into it tomorrow once I've slept :)

Bobbie Wilson

unread,
Apr 13, 2012, 2:19:28 AM4/13/12
to wordpres...@googlegroups.com
If you need help tomorrow, just email =)

trey trey

unread,
Apr 13, 2012, 2:19:46 AM4/13/12
to wordpres...@googlegroups.com
Sounds very interesting, keep us posted.  

Trey

On Thu, Apr 12, 2012 at 5:18 PM, Bill Woodland <squ...@austin.rr.com> wrote:
--
You received this message because you are subscribed to the Google Groups "WordPress Austin" group.
To post to this group, send email to wordpress-austin@googlegroups.com
To unsubscribe from this group, send email to wordpress-austin-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/wordpress-austin?hl=en

Our meeting information is available at http://www.meetup.com/austinwordpress/

trey trey

unread,
Apr 13, 2012, 2:35:55 AM4/13/12
to wordpres...@googlegroups.com
Great job Bobbie :)


To post to this group, send email to wordpres...@googlegroups.com
To unsubscribe from this group, send email to wordpress-aust...@googlegroups.com

For more options, visit this group at http://groups.google.com/group/wordpress-austin?hl=en
 
Our meeting information is available at http://www.meetup.com/austinwordpress/

Bobbie Wilson

unread,
Apr 13, 2012, 2:39:05 AM4/13/12
to wordpres...@googlegroups.com
Thanks Trey!

Dmitri Wolf

unread,
Apr 13, 2012, 8:28:37 AM4/13/12
to wordpres...@googlegroups.com
I like Bobbie's solution! Very neat.

But if you need the sales people to be able to access each other's pages also, then each one should have their own page, which can be created with this function when they register:

function create_page($templateName="sales_dashboard_template.php", $postParent=0)
{
    global $user_ID;
    global $current_user;

    $pageTitle=$current_user->display_name . "'s Dashboard";

    $page['post_type']    = 'page';
    $page['post_content'] = 'Put your page content here';
    $page['post_parent']  = $postParent;
    $page['post_author']  = $user_ID;
    $page['post_status']  = 'publish';
    $page['post_title']   = $pageTitle;
    $page = apply_filters('yourplugin_add_new_page', $page, 'teams');
    $pageid = wp_insert_post ($page);
    if ($pageid == 0)
    {
        /* Add Page Failed */
    } else {
        // update the template
        update_post_meta($pageid, '_wp_page_template', $templateName);
    }
    return $pageid;
}

The can all be children of the "My Dashboard" page if you set the $postParent variable to that page's id.

Hope that helps!
Dmitri



On Thursday, April 12, 2012 11:36:36 AM UTC-5, Squeek wrote:

Bobbie Wilson

unread,
Apr 13, 2012, 8:36:56 AM4/13/12
to wordpres...@googlegroups.com

Thanks Dmitri.

Nice function!

Bobbie

--

Bobbie Wilson

unread,
Apr 13, 2012, 12:21:47 PM4/13/12
to wordpres...@googlegroups.com
Dmitri,

I tried using this function at first, pulled from the codex:
function my_login_redirect($redirect_to, $request){
    global $current_user;
    get_currentuserinfo();
    //is there a user to check?
    if(is_array($current_user->roles))
    {
        //check for admins
        if(in_array("administrator", $current_user->roles))
            return home_url("/wp-admin/");
        else
            return home_url("author/" .$current_user->user_login.);
    }
}
add_filter("login_redirect", "my_login_redirect", 10, 3);
It redirects to /author/ but doesn't include the user login after that. Do you see what I'm missing?

Thanks
Bobbie

Bill Woodland

unread,
Apr 13, 2012, 5:45:44 PM4/13/12
to wordpres...@googlegroups.com
This is what I love about this group; ask and ye shall receive. I hope
one of these days I'll know enough to give back.

Thanks to Bobbie and Dmitri. I'll get working on this very soon, as
they want it done by....well, very soon.

Dmitri: No, they shouldn't see each other's pages, but each one having
their own actual page is better for the sake of privacy, and also for
the chron job to update each page when necessary.

which brings me to the Peter's Login Redirect plugin that Bobbie
mentioned. Since it can be set to redirect for specific users, then I
think this plugin will work well for me.

Between both of your suggestions, I believe I can get very close to what
my client needs.

Happy Friday the 13th :)

Dmitri Wolf

unread,
Apr 13, 2012, 6:03:42 PM4/13/12
to wordpres...@googlegroups.com
Bobbie,

Let me take a look at that...
Right away I can tell that the compiler isn't going to like that extra period after ->user_login.
else
            return home_url("author/" .$current_user->user_login.);

Bobbie Wilson

unread,
Apr 13, 2012, 6:10:12 PM4/13/12
to wordpres...@googlegroups.com
That was a copy/paste artifact...sorry =)

Dmitri Wolf

unread,
Apr 13, 2012, 6:22:32 PM4/13/12
to wordpres...@googlegroups.com
Bobbie,

It's working for me with this code:
        <?php
        global $current_user;
        echo "<p>Current user login is: " . $current_user->user_login . "</p>";
        $url = home_url("/wp-admin/");
        echo "<p>Home Url admin: " . $url . "</p>";
        $url = home_url("author/" .$current_user->user_login);
        echo "<p>Home Url author: " . $url . "</p>";
        ?>

Producing this output when logged in as user 'MyOtherGuide':

Current user login is: MyOtherGuide
Home Url admin: http://localhost/wp_guides/wp-admin/
Home Url author: http://localhost/wp_guides/author/MyOtherGuide

When not logged in this is the output:

Current user login is:
Home Url admin: http://localhost/wp_guides/wp-admin/
Home Url author: http://localhost/wp_guides/author/

Maybe if you break it up, assigning the value of home_url() to a variable, then returning that, it will work.
Sometimes when you re-write code it fixes the error.

Give that a try and let me know what happens!

Bobbie Wilson

unread,
Apr 13, 2012, 9:38:59 PM4/13/12
to wordpres...@googlegroups.com
Dmitri,

I got it working. All I had to do was change $current_user to $user.

<code>
function my_login_redirect($redirect_to, $request){
    global $user;
    get_currentuserinfo();
    //is there a user to check?
    if(is_array($user->roles))
    {
        //check for admins
        if(in_array("administrator", $user->roles))
            return home_url("/wp-admin/");
        elseif
            (in_array("subscriber", $user->roles))
return home_url("author/" .$user->user_login);
else
return home_url();
}
}
add_filter("login_redirect", "my_login_redirect", 10, 3);
</code>

So Bill, if you would like to use that instead of the plugin, it will do the same thing. Just place it in your theme's function file. You can change the contents of home_url if you're creating separate pages, as Dmitri coded.

Bobbie


Bill Woodland

unread,
May 15, 2012, 11:45:16 PM5/15/12
to wordpres...@googlegroups.com
Thanks for that, Bobbie and Dmitri. I'm finally getting to work on this.

Dmitri: The idea of separate pages for each user might be nice in some
cases, but in this one, I think I'll do all of the work in the page
template. Still, I appreciate the effort. You never know when that
situation might arise.

Bobbie:
Your role function looks like it will be very useful on another project
I'm doing pro bono (it's a site for myself :)


The page shows up in the menu whether you are logged in or not, so I
need to add is_user_logged_in() to the template, and stick em where the
sun don't shine (login page) if they're not.

The bulk of the other coding will be done in widgets, and this page will
be the only one with a sidebar. I'll need a few other custom fields in
the user table to give me their sales agent number, etc., which will be
used by the widgets to display:

their latest 4 reports
any new business
any past due customer payments
month to date sales

Thanks again for all the help. Maybe I'll see you Saturday at
http://2012.austin.wordcamp.org/
Reply all
Reply to author
Forward
0 new messages