Nested s2If - Suggestion for Alternative Syntax

Hi!

Just a quick suggestion. It would be nice to have it handling nested conditionals without requiring opening underscores, if possible, in the future.

When you work with blocks sometimes you don’t know which context your content will be inserted into, then things break when there’s collision of the same levels.

If the system could handle it like a regular programming language (at least as a fallback, no need to remove the current syntax) that would be great.

I just noticed a few pages broken and I can’t simply fix it because I have reusable blocks with conditionals that might be presented directly or under other conditionals, depending where they were used.

Unlinking isn’t a good alternative either, as one of the major benefits of reusable blocks is to have them updated automatically across your entire site, when necessary.

Just a suggestion, of course. :pray:t2:

Have a nice day!

So you have a block inside a nested s2If and that doesn’t work?

You’re using the gutenberg editor, right? how are you applying the shortcodes, one shortcode block for the opening one and another shortcode block for the closing one?

If the system could handle it like a regular programming language (at least as a fallback, no need to remove the current syntax) that would be great.

What do you mean by that? That they’re all s2If and the system figures out the nesting? That wouldn’t be so easy, because the shortcode parser is WordPress’, not s2Member, and it would not pair them correctly… e.g.

[s2If current_user_can(access_s2member_level1)]
hello
[s2If current_user_can(access_s2member_level0)]
there
[/s2If]
[/s2If]

results in

hello

there
[/s2If]
1 Like

Yes. This is the issue. Never mind if hard to implement.

I have reusable blocks that have s2ifs inside.

Those blocks can be used freely on regular pages.

Sometimes those SAME blocks can be used in areas of pages that are only visible to certain users, for example.

I guess a solution is to do this, instead, for those reusable blocks (add more leading underscores, I tested and I don’t seem to need to have previous higher level ones for them to work):

[____s2If current_user_can(access_s2member_level1)]
hello
[_____s2If current_user_can(access_s2member_level0)]
there
[/_____s2If]
[/____s2If]

Thanks again! I guess this can be useful if anybody faces the same issue in the future.

:innocent:

1 Like

Great! :slight_smile:

1 Like