Simple Members Only Section
June 10th, 2008
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.


