WordPress.org

Ready to get started?Download WordPress

Forums

WP-Members
[resolved] Hide a div when users not logged in? (5 posts)

  1. Brian KD
    Member
    Posted 1 year ago #

    I would like to use this plugin to hide everything in a div when members are not logged in. Is there an easy way to do this?

    I've tried to use the [wp-members status="in"][/wp-members]. I also tried to use some javascript to hide a div when another div is not present, but my javascript wasn't valid or perhaps the "inline-javascript" plugin I tried to use is bogus.

    Is it possible? Thanks,

    -Brian Peterson

    http://wordpress.org/extend/plugins/wp-members/

  2. Chad Butler
    Member
    Plugin Author

    Posted 1 year ago #

    I assume since it is a div you are hiding, this is in the template, not the content? If that's the case, you can't use a shortcode.

    You can use is_user_logged_in().

    <?php if( is_user_logged_in() ) { ?>
    
    <div>my content</div>
    
    <?php } ?>
  3. Brian KD
    Member
    Posted 1 year ago #

    The content is being generated in a plugin. I may still be able to use the shortcode by inserting it into the plugin's output (seems logical enough). I've contacted the other plugin author for assistance. It's a B&B website and we don't want people to be able to book unless they're a registered member. Your code snippet may be all we need. Thanks,

    -Brian Peterson

  4. Chad Butler
    Member
    Plugin Author

    Posted 1 year ago #

    That's actually not as logical as you might think. It depends on when that plugin's output is being handled (which would depend on various actions/filter hooks that it might be using). The WordPress shortcode parser fires only once, so if the plugin is firing after that, the shortcode wouldn't be parsed.

  5. Brian KD
    Member
    Posted 1 year ago #

    That's interesting that the parser fires only once and probably explains my experiences. I attempted a few insertions of the shortcode tags but each time they were printed out as a string. Fortunately for me the other plugin author said he was implementing what I needed in his next update in 2 weeks so this issue will be resolved then. Thanks Chad,

    -Brian

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.