Member Shortcode and Elementor

Hi

I’ve recently updated my home page using Elementor - https://sippclub.com/ - when someone has logged into S2Member, they shouldn’t see the yellow box entitled ‘Weekly News’ because we already have their email address. I’ve previously removed this section using these shortcodes…

[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]

However, I can’t seem to make it work using Elementor.

If it’s possible, how do I do it?

Thanks.

Brian

That would be a question for Elementor support probably.

There are three reasons why the S2member shortcodes would not work that I can think of:

  1. Your page editor is sticking <p> or <br> into the shortcodes. Check in your editor in TEXT mode
  2. Elementor block you have put the shortcodes in does not parse shortcodes
  3. Elementor post content parser uses internal parsing conventions that collide with the s2member shortcode conventions (I had this happen before where my theme automatically put shortcodes on a new line and ended up splitting the shortcode into two pieces on two lines)

If you see nothing on the page then it is probably scenario 2. Try a different Elementor block type that supports shortcodes.

Let us know how you go. I’m sure there are other Elementor / S2member users in our community who would be interested in the answer.

Thanks Tim.

I’ve tried an Elementor block that supports shortcodes, but I couldn’t get it working. Sadly, I have no IT knowledge - only what I’ve picked up along the way by trial and error. So unless it’s a simple solution, I guess I’ll have to give up.

Brian

Others have reported S2Member shortcodes work in Elementor but they reported this on a previous release. See Is S2 Members and Elementor Page Builder Compatible?

You did not say if the shortcodes are being displayed as text or if the shortcode text you enter is not being displayed. If the shortcode parser in elementor is not operating then all the shortcode text will be visible without modification. If the elementor shortcode parser doesn’t like the shortcode then it just erases it.

NOTE: If you can make a test page that does not use elementor and the shortcode works then we know it is a elementor issue. Contact Elementor support.

Thanks Tim.

The S2Member shortcodes definitely work, because they’re in place and working as they should be on the current home page - https://sippclub.com/

When they are placed into Elementor blocks, the first shortcode disappears, but the final shortcode is displayed as text.

A mystery.

I’ll contact Elementor support and let you know what they say.

Thanks.

Brian

Ok…that’s what I was looking for you to tell us. You are experiencing scenario 1 above. The dreaded wpautop flaw that has been around in WordPress for a decade.

Try putting it all on one line…

[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]

Using the ‘shortcode’ block, the code shown in my original message on this thread works perfectly whether it’s on many lines, or all on one line. Text works perfectly, but I want to display more than text (ie the section headed ‘Weekly News’), as I’ve indicated in my original message.

Brian

I’m confused. I thought your problem was that it worked in a non-elementor page but did not work in an elementor block! You did say:

I’ve tried an Elementor block that supports shortcodes, but I couldn’t get it working.

Now you’re saying it works fine and your problem is that you want to display other information.

Please restate your problem.

Sorry Tim if I’ve confused you. The shortcode is working fine on a non-Elementor page (either as one line or many lines). But it’s not working on an Elementor page (either as one line or many lines).

Brian

Ahhh…ok. That’s what I was looking for. Did the 1-liner fix work in the Elementor block…it sounds like it didn’t.

To double-check…is this an Elementor block or an Elementor Block for Gutenberg? See https://elementor.com/blog/blocks-for-gutenberg/ Restating…is this an Elementor block on a Classic page or an Elementor Gutenberg Block on a Gutenberg page, or an Elementor block in a Gutenberg Classic block on a Gutenberg page (if that is even possible with Elementor)?

To double-check this problem I would edit the block in text/html mode rather than visual mode and see what it looks like. Usually the problem is that the editor auto-injects junk html that mucks up the shortcodes.

If this is an Elementor Gutenberg block then you can edit it in text mode. See what it looks like.

If this is and Elementor block on a classic page I am not sure if Elementor offers a text mode to edit a Elementor block. I’m not an Elementor user.

I only tried an Elementor block called ‘Shortcode’. I don’t know what Gutenberg is.

If I try to go back to the WordPress Editor, I get the warning message “Please note that you are switching to WordPress default editor. Your current layout, design and content might break.” I tried it anyway with the shortcode on one line and many linees, but neither worked.

I’ve posted the original message on the Elementor Community Facebook page a few days ago, but I’ve not received a comment yet.

Brian

When you get the message “Please note that you are switching to WordPress default editor" then you are on a Gutenberg page switching to a classic page. When you do that WordPress will convert your page content and the results may be unpredictable if Elementor is in the mix.

Up until WP5.0 the old style editor was in use. This is now referred to as the “classic” editor. Since WP5.0 WordPress has two editors for you to choose from…the “classic” editor and the new “Gutenberg” editor.

Elementor blocks were originally designed to be used in the “classic” editor. For backward compatibility the “Gutenberg” editor offers a “classic block” and a “classic shortcode block” for legacy shortcodes.

So to run a Elementor block on a “Gutenberg” page you would put it into a Gutenberg “classic block” or “classic shortcode block”.

To confuse things further Elementor has releases some native Gutenberg blocks.

So I don’t know whose block you are using…Elementor’s classic shortcode block in a Gutenberg classic block or a Gutenberg block or an Elementor Gutenberg block!

And if you switch your page between classic and Gutenberg, WordPress will convert all the content. Normally that yields accurate results but I would not count on that in this case since Elementor is a page builder.

My recommendation if you want to use Elementor is to disable Gutenberg site-wide then try again using a “classic” site. Your site is a messy soup right now. Or, as an alternative, make your site Gutenberg and drop Elementor. Your choice.

Thank you so much, Tim, for taking the time to try to help me. I thought it might be easier than expected, but sadly, it’s not the case.

I have no IT knowledge, as I’m a mere pension adviser, struggling to make this work. As a result, I think I’ll give up for now as my head hurts, and instead, consider employing the services of someone who understands what they’re doing.

Thanks again.

Brian

You are welcome Brian. Sorry this wasn’t an easy low-tech fix. You are getting caught up in a transition from the old WordPress world to the new WordPress world which will persist until mid 2021.

Don’t give up though. Your best bet is the Elementor support forum. They will be better equipped to point you in the right direction.

Thanks Tim. I thought that’s what I found on Facebook. Do you have a link to it, please?

Brian

There appear to be 3 to choose from: Facebook, GItHub, paid. If you want a fix quickly paid support would hopefully get you a quick answer / fix. Otherwise, you have raised it on Facebook, I would suggest you raise the issue on GitHub. https://github.com/elementor/elementor/issues

If you don’t want to pay then GitHub may get you an answer where the Facebook community does not.

NOTE: There was an old issue in GitHub that sounded like yours. They had a collision with Yoast SEO plugin. If you can turn off as many nont critical plugins as possible and retest with s2member (preferably as the lone active plugin if possible) your problem might go away.

Thanks Tim, great help once again.

Glad to be of help. It would be great if you could post an update in this topic once you get it sorted so that other community members might benefit from your solution once Elementor support helps you out.