Show Content To LOGGED OUT Users (3 posts)

  1. Lab41
    Posted 2 years ago #


    I love this plugin and find it super useful. I'm trying to show a message "please login...." to everybody who is logged out. I don't want logged in users seeing this message.

    "[is_user_logged_in]This content is only shown to logged-in users.[/is_user_logged_in]"

    Does the oppposite. I want to do:
    [!is_user_logged_in]This content is only shown to logged-in users.[/!is_user_logged_in]

    What's the best way of doing this?

    I've also tried:
    [access role=""]Content Here[/access]
    But that just shows it to nobody.

    Any ideas on how to do this?


  2. srkennedy
    Posted 2 years ago #

    I'm currently looking into the same thing. The plugin only seems to hide the content with the [access] shortcode when applied to template files and doesn't display the error message.

    So my workaround I was looking to do was:

    <?php if ( !current_user_can( 'read_pages ' ) ) { ?>
                Error message here.
    <?php } ?>

    This could probably work for you if you are putting it in a template file.

  3. Lab41
    Posted 2 years ago #

    Could I put that code in my theme functions.php? Or do I need an exec php plugin? I'd prefer to avoid the extra plugin route if possible.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Members
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic