WordPress.org

Support

Support » Plugins and Hacks » People Lists » [Plugin: People Lists] Only show fields to logged in users

[Plugin: People Lists] Only show fields to logged in users

Viewing 3 replies - 1 through 3 (of 3 total)
  • schmunk,
    I’m not connected with the developer of People-lists at all, but found a CSS-only solution for me that works pretty well (to visually hide the private content).
    In the People-lists template builder, I added a class of private, like this:
    <div class="user-address1 private">%people_lists_address1%</div>
    Then, I added a couple of style rules to my CSS stylesheet, like this:

    div.private {
    	display: none;
    }
    .logged-in div.private {
    	display: block;
    }

    And by the magic of WordPress, when a div with the class private is found, it’s hidden.
    When a div with the class private is found within the class logged-in (which is added to the body tag automatically by WP, hence the “magic”), the div is displayed as a block (the default for divs).
    Ta-da!
    NOTE: This does NOT actually keep the information out of the page, it just hides it from visual clients. The content is still there, in the code, and can be seen by search engines. To actually have the content not added to the page, I had to create two lists, a private one and a public one, and put the private one on a separate page. It may be possible to do something with is_user_logged_in within the page template, to add the private list shortcode or the public list shortcode, but then it’s getting pretty complicated, and a lot of the plugin’s ease is lost…

    Neat trick!
    I ended up creating two seperate lists.

    Then i used logged in shortcode to show the lists in one page.

    http://wordpress.org/extend/plugins/logged-in-user-shortcode/

    [loggedin]private list[/loggedin]
    [loggedout]open list[/loggedout]

    That’s cool. I hadn’t seen that one. That sounds like it provides an easier, shortcode way of doing the is_logged_in thing, without having to make a separate template and code the lists right into the template (since normally you can’t execute PHP code in the page editor).

    I may have to look that one over…

    Thanks for the tip!
    Robert

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: People Lists] Only show fields to logged in users’ is closed to new replies.
Skip to toolbar