Shortcode and Paragraphs not being parsed in protected content message

I have a protected page where I placed a shortcode to allow non-members to sign up for the membership that would allow them to view the content in question.

The page is not parsing the shortcode, and it's also not breaking for paragraphs properly.

You can see the problem at:

At the top of the page, the content above the login area is the part I set up in M2 >> Settings >> Protection Messages >> Content protection message.

I put my content and shortcode in the "text" tab, not the visual tab. I put a hard return after each sentence and the shortcode on its own line (and it shows as three separate paragraphs if I switch to visual tab). But on the live page, you can see that it is all run together as a single paragraph and the shortcode is not being parsed at all.

Any idea why or how to fix?

  • Michael Bissett

    Hey kalico, Michael here! :slight_smile:

    As to the fixing of this, you'll want to edit line 595 of:


    From this:

    $html .= $protection_msg;

    To this:

    $html .= apply_filters( 'the_content', $protection_msg );

    That should get this going for you. I'll bring up this change to the developer, I'm aware of allowing shortcodes like this being a feature request.

    Kind Regards,

  • kalico

    Thanks, Michael.

    I don't really want to edit plugin files....if the functionality does not get changed, I will have to re-edit every time the plugin is updated, and keeping track of that is always messy. So this can go down as a feature request, but I will keep the message simple for now.

    Additionally, I've since discovered that this "protected content message" is just that -- a short message. In fact, it's displayed by a shortcode of its own.....[ms-protection-message].

    According to the Membership 2 >> Help >> Shortcodes description of [ms-protection-message]:

    If the user is not logged in this shortcode will also display the default login form. If you provide your own login form via the shortcode [ms-membership-login] then this shortcode will not add a second login form.

    So, I guess I don't need to add the shortcode to the message as I originally thought. It should probably just be in the "Protected Content" PAGE rather than in the protected content MESSAGE.

    This is pretty confusing, but I'm slowly getting the hang of it. I hope documentation will be improved, because the feature set is really rich. :slight_smile:

    If you think I've misunderstood something, please let me know. I'm still having some other issues with this process, which I posted in another support request, so I know I haven't got it all figured out and working right yet. But in general, this particular issue is resolved.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.