Custom post restriction messages in Restrict Content Pro

Set up custom page restriction messages in RCP

When a website visitor doesn’t have access to restricted content, Restrict Content Pro has two settings to control the message that is shown: one for content that requires a paid subscription, and one for content that requires a free subscription. This works great for people who want fine-grained control over the upsell messages they show to people without an active subscription, but sometimes they want a custom message for a specific page to further refine their upsell messaging. Let’s look at how that can be done.

Enabling custom page-level restriction messages

To set up a custom restriction message at the post/page level, you need to get your hands dirty with a little code. No worries, though, it’s pretty easy.

The best place to put this code is in a custom plugin. If you’re not familiar with how to create a custom plugin, you can install Pluginception, use it to create a new custom plugin, paste in the code below, and activate your new custom plugin.

Now let’s get to the code.

https://gist.github.com/mindctrl/e6293f39c0462972e75935570cee0768

How it works

The code above adds a new section to the Restrict this content box on the page edit screen. This is what it looks like.
Restrict Content Pro custom page restriction messages

That’s all there is to creating a custom restriction message for a page. If a visitor doesn’t have access to a piece of content, and you have a custom restriction message defined, the visitor will see that custom message instead of the global one defined in the RCP settings. Here’s a look at the example created in the screenshot above.
Restrict Content Pro custom page restriction message on the front end

And as always, if a page doesn’t have a custom restriction message defined, the global setting defined in Restrict Content Pro’s settings page under Restrict → Settings → General is used.

That’s all there is to it!

5 thoughts on “Custom post restriction messages in Restrict Content Pro

  1. triviumchina says:

    Doesn’t look like the metabox here runs shortcodes, and it would be awesome to run RCPs native shortcodes to be able to show different restriction messages depending on user’s memebership status. Any tips for adding shortcode functionality to the metabox? Thank youuu!

    • Hey, Alex. Sorry, I can’t say for sure. I haven’t worked on RCP or Woo in over a year now, and a lot has changed in both. And there’s the Gutenberg stuff, which in certain cases can affect metaboxes. Unfortunately I probably won’t have time to dig into that use case. If you find a solution, I’d love to hear it here in the comments.

Leave a Reply