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.

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!

Leave a Reply