How to use conditional short code

I want to hide a “Join Here” button from logged in users. I see all the fun stuff at: [

[s2If /] Simple Shortcode Conditionals | s2Member®](

I’m new to s2member / php and need to ask – Where does all this code exist? I don’t know what file to edit to add short code on whether or not to display a button. An example of hiding a button to logged in users with level 0 or higher would be appreciated.


I think I can answer my own question on hiding a button. I found this technique that does not use short code by creating a child theme, a couple of classes in functions.php and using CSS.

[Display Conditional Content with Elementor for Logged In/Out Users

Maybe my question strays from the s2member product, but if I want to use s2member levels in my logic, if this the technique I should be using? Thanks!

I use Elementor and use the conditionals very often.
If you want to display something to non-logged in members, you can just use something super simple, like this:

[s2If !is_user_logged_in()]
content for the not-logged in visitor like a button or a reminder to log in

and if you want to display something else for the logged in members (the difference is the exclamation mark that means “not”):

[s2If is_user_logged_in()]
content for the logged in members

I use that very often to remind members to log in, or for non-members to join, and I also have some exclusive content for the members themselves.

Thank you very much for the simple answer. Love simplicity! Where does this short code go when wanting to control the visibility of the button? Thank you! Bob

Oh, I guess you are using a button widget in Elementor? I have not used that myself. However, I know of an additional plugin for Elementor called Dynamic Visibility (very convenient plugin) that has the option for Custom Condition with their paid version. I use that plugin often for date/time conditions (available with the free version).

If you are able to use an html or a text widget to insert your button, then, you can use that shortcode as is.

To follow-up on what I did – I have a strong desire to stay out of php code to keep upgrade issues minimized. So, I found a plugin: Restrict for Elementor that provided a free solution to control visibility.

1 Like