Category only for logged in users

Community Forums Forums General Discussion Category only for logged in users

This topic is: not resolved

This topic contains 4 replies, has 2 voices, and was last updated by  Heinz 1 year ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #64256

    Heinz
    Participant
    Post count: 18

    Hi 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


    #64258

    braddalton
    Participant
    Post count: 10174

    Which 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/


    #64260

    Heinz
    Participant
    Post count: 18

    Hi 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


    #64312

    braddalton
    Participant
    Post count: 10174

    I 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.


    #64442

    Heinz
    Participant
    Post count: 18

    I 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?


    • This reply was modified 1 year ago by  Heinz.
    • This reply was modified 1 year ago by  Heinz.
    • This reply was modified 1 year ago by  Heinz.
    • This reply was modified 1 year ago by  Heinz.
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.