Level specific message
Changing your default “access denied” message for posts and pages is, as you know, fairly easy in Paid Memberships Pro:
[s3mm type=”video” files=”change-access-denied-message.mp4″ titles=”Change ‘Access Denied’ message in Paid Memberships Pro”]
But what if you want a custom message for a membership level? A custom message that will be different, depending on the membership level needed to access that post or page?
Doing that is unfortunately not quite as simple…
It requires using a couple of different WordPress/PMPro filters and creating PHP code.
The good news?
We’ve created some custom code you can use (See below).
The code is pretty – we think – easy to add to your site. As simple as a “copy and paste” operation:
- Create an empty
custom_advanced_settings.phpfile in a
custom-advanced-settingsdirectory on your computer/laptop
- Copy the entire contents of the PHP script below
- Paste it into the new
- Edit the
pca_get_level_messages()function to both match your Membership Level IDs – found on the “Membership Levels” settings page for Paid Memberships Pro – and edit the text for your message.
There are 3 different messages you can edit:
not_logged_in message is used when the user attempting to access a post or page (the content) but is not logged in to the system.
rss message is used when someone is denied access to the RSS stream for that post/page.
non_member message is used when the user is logged in, but they do not have the correct membership level to see the post/page they’ve navigated to.
In the comments, there’s
Format: section which explains what the structure needs to look like. It’s a fairly straight forward PHP
array() of arrays() structure.
The membership level ID is the key that helps us identify which messages we can choose from.