WordPress.org

Ready to get started?Download WordPress

Forums

Members
Show Content To LOGGED OUT Users (3 posts)

  1. Lab41
    Member
    Posted 5 months ago #

    Hi

    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?

    https://wordpress.org/plugins/members/

  2. srkennedy
    Member
    Posted 5 months 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
    Member
    Posted 5 months 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.

Reply

You must log in to post.

About this Plugin

About this Topic