Sponsors

ad

ad

Want to advertise here? Go to Text link Ads.

Text Link Ads


Internet Blog Top Sites
« Tagaroo - Intelligent Tag Suggestions | Home | For Developers - Display Page and Post Ids »

Simple Members Only Section

June 10th, 2008

simple-members-only-section

Recently, while helping someone setup a members only section on their site, I found that there wasn’t an obviously simple solution that worked with 2.5.x. Several plugins exist that attempt to solve the problem, however, as I said, they are either no longer available, don’t work in 2.5.x, or simply are ridiculous solutions.

The site in question simply wanted certain pages for members (from a subscription based service). There was no budget to do anything fancy like have a shopping cart integrated with user creation, just a simple way to add the 50+ existing members and new members. So after poking around and wasting my time trying to adapt the aforementioned plugins, the venerable Role Manager plugin seemed to fit the bill fairly easy for my needs. Members can be added as subscribers, turning off registration for the site. Subscribers can be edited to view private pages. Voilá!

As far as adding the initial 50+ members, though not tested yet, Dagon Designs Import Users plugin seems to fit the bill, and since I’ve been using their forms plugin, I have confidence this will work quite well.

Finally, by default, when you list a page that is private, you get a Private: prefacing the page title. Well, that’s not exactly what I want, so I found several different, though similar solutions. Simply add a function to your theme’s function.php file to either strip or change the output.
function remove_private_prefix($title) {
$title = str_replace(
'Private:',
'Members Only - ',
$title);
return $title;
}
add_filter('the_title','remove_private_prefix');

Where you can either change the “Members Only - ” to what ever you want, or leave it out, ie, ('Private:','',$title);.

I’m sure some issues will crop up, and I will follow up after I’ve fully implemented the ideas I’ve outlined, but I wanted to share the thought process (and possibly save someone the same time consumption googling every combination of “wordpress/members/pages/private” they can come up with) as well as document it for my own reference. Any other tips would be greatly appreciated.


Possibly Related:


Get a Trackback link

1 Trackbacks/Pingbacks

  1. Pingback: Wp Wordpress » Blog Archive » Simple Members Only Section on June 10, 2008

2 Comments

  1. Jodi, June 19, 2008:

    I am so glad I came across your article. We are in the process of migrating our membership site from a remotely hosted service to WordPress. Using Role Manager, I’ve setup our user groups and was happy with the setup… other than having “Private:” at the start of restricted posts. I found the section of the posts template that spits out that text, but I’m not one to hack core files (because you always have to remember what you did when you upgrade later!)

    Your function works perfectly! It lets me mark the article as “Members Only” rather than “Private”, which is exactly what I wanted.

    Now, the only things I’m left struggling with is getting the private posts to show in the “Recent Posts” block if a user is logged in and has permission to view that article. I’ll keep Googling and maybe I’ll turn up a solution.

    Thanks again for the function. Works like a charm!

  2. Miklb, June 19, 2008:

    My pleasure. I too am still trying to sort out how to get Pages marked private to show up in some navigation, I’m sure the issue is related. Please report back if you find a solution, and thanks for commenting.

Leave a comment