Community Forums › Forums › Archived Forums › General Discussion › Category only for logged in users
- This topic has 4 replies, 2 voices, and was last updated 12 years, 9 months ago by
Heinz.
-
AuthorPosts
-
September 26, 2013 at 1:30 am #64256
Heinz
MemberHi forum,
we use a member-plugin to present protected posts to logged-in users only. But we want to hide also a complete category. Logged-in users should be able to see the category with the list of recent posts, others should see the login form instead.
We think about creating a category.php file, and remove the genesis_do_loop() for anonymous users for this protected category. How can we then place the login form there? Hard-coding in that category.php file?
Thank you in advance,
Heinz
September 26, 2013 at 1:56 am #64258Brad Dalton
ParticipantWhich membership plugin are you using?
Here's a post which includes 5 ways to remove posts in specific categories from displaying. http://wpsites.net/web-design/exclude-category-posts-page/
September 26, 2013 at 2:08 am #64260Heinz
MemberHi Brad,
in that case wp-members. But we do not use it for lock/unlock of posts, but for user handling only. The authors should not be forced to use a custom field. When they post into a certain category, the posts should be automatically protected, including the whole list of posts of that category.
The question really is: how can I show the entire list of posts of a specific category to logged-in users only, and present a form to all others (using Genesis; and for the category itself, i.e. without using a category page template).
Heinz
September 26, 2013 at 12:05 pm #64312Brad Dalton
ParticipantI would use a plugin like s2members or members by Justin Tadlock. Both plugins enable you to do hide posts in specific categories.
s2Member allows you to protect Pages, Posts, Tags, Categories. This is the best members plugin in my opinion.
September 27, 2013 at 3:48 am #64442Heinz
MemberI once installed S2members, but decided to not use it for simple cases. It left a mess when I deinstalled it again.
Anyway, my question is not about how to handle registered users (this is already well handled by plugins like "members" oder "wp-members"), but about how to show a whole category only to logged in users, and provide other users some text or a form instead.
So it must be something like:
Creation of a file category.php
and then:<?php if ( is_category(12) || is_category(27) ) { if ( !is_user_logged_in() ) remove_action('genesis_loop', 'genesis_do_loop'); } else { echo '<h2>Member Area</h2>'; echo '<p>Please log in.</p>'; // login form here } } genesis(); ?>Essentially this works, but the else-part misses a lot of structuring HTML-elements. Of course these can be added manually with echo-statements, but maybe we could remove something else than the whole loop?
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.