[s2If /] shortcode breaks page

I’m attempting to use this simple shortcode conditional, per the kb

[s2If is_user_logged_in()]
    Content for anyone that is logged in, regardless of their Membership Level.
[/s2If]

[s2If !is_user_logged_in()]
    Some public content. They're NOT logged in.
        A leading !exclamation means false.
[/s2If]

The content for when user is logged in works fine.
But when i’m not logged in i just see a blank page. All other page content is missing.

please tell me i’m missing something obvious

Have you checked the dev console for error messages? Press the F12 key and then click on Console to see any error messages being reported by the page. If there aren’t any messages displayed there you might want to to turn on WordPress error logging and check for PHP errors. Also check to make sure you’re not being redirected somewhere when you’re not logged in (is this code on a restricted page/post?) – check the URL to make sure it is the same as the URL you see when you ARE logged in. That’s all I can think of without more troubleshooting information. Feel free to report back here with any error messages or if the URLs are different.

1 Like

Hey thanks for the reply!
I was missing something obvious… and have fixed it.

I forgot I used some custom code ages ago with the content filter hook to render a conditional <div /> for logged in users. But had a null return instead of $content for users not logged in.

Fresh mind in the morning always leads to solutions :slight_smile:

Shoud i delete this thread? seems a bit silly now…

2 Likes

No need to delete it. And it may help someone in the future.

Thanks for the update! I’m glad you sorted it out. :slight_smile: