Easy Restrict Content for WooCommerce: Documentation
Welcome to the documentation, we’ve got a few parts. Click on one of them to jump to the section.
You’ll find both written and video explanations for most of the plugin setup. Oh and of course screenshots. Who does documentation without screenshots? People who don’t value documentation, that’s who.
Developers, there are code samples for each filter available.
If you still have questions about how to use the plugin shoot me an email at email@example.com.
Basic plugin installation
Before you install this plugin make sure you have downloaded WooCommerce and activated it. This plugin requires WooCommerce to work and will deactivate itself if WooCommerce is not an active plugin on your site.
Once you have WooCommerce installed and active start by getting the plugin installed and activated and of course use that license you have.
You should receive an email with your download link and your license key. You can also find this information in your user account.
Click the download link for your plugin. You’ll also need the license key from your purchase thank you page or the email you were sent.
If you have FTP access then you will need to open the zip file and upload the folder to your wp-content/plugins folder on your server.
If you do not have FTP access to you site you can upload the .zip file directly to your WordPress install by going to Plugins and Add New.
Then select ‘Upload’ and use the file choose dialogue to choose the .zip file you were provided with.
Once the plugin is uploaded choose ‘Activate Plugin’.
Now you should have a new menu item called SFN License under the WooCommerce menu. Click this and it will take you to the license activation page.
Now you need to copy/paste your license key in to the field provided. Once you have done that and clicked save an ‘Activate’ button will show up. To get automatic updates click Activate which will register your license with this site for automatic updates.
Once you click activate you should see a green ‘active’ beside the button and it should offer you the option to deactivate.
You can also manage your active sites via your account on this site.
Whew that was a bit of work but now we’re ready to rock along and restrict our content from the prying eyes of non-purchasers of your lovely WooCommerce products.
Restricting Pages or Posts
The process to restrict pages/posts is the same so we’ll go over it once for you.
Of course the first thing you need to do is setup a product in WooCommerce. If you don’t know how to do that then I have a lovely video on YouTube to show you how to set up a basic WooCommerce product.
Once you have your product set up visit a WordPress post that you want to restrict to product purchasers.
Once you are on the post you should see a ‘Restricted Content’ box on the right hand side of your screen somewhere below your post publishing functions. How far below depends on how many other plugins you have that add content to the right hand side of your post screen.
Now click on the select box and choose a product. If you are having a hard time finding it in a long list, start typing inside the box and it will filter products based on what you type.
When you find the product you want to restrict the page by click on it to select it.
Then save the post.
If you’re restricting a page you’ve got a few more options. You can choose to remove the page from the WordPress menu as well as from the My Account page in WooCommerce.
If you’d like to add a custom message to the page then you’ll need to look at the ‘Custom Restricted Message’ box.
Check the first box titled ‘Add a custom message’ and you’ll then see the custom message content area.
Put any text/links you’d like to show the user here and it will override the stock restricted content message.
Restricting bbPress Forums
Okay now it’s time to show you how to restrict bbPress forums.
Start by adding the bbPress plugin to your site via the plugins menu.
Once it’s installed and activated go to the ‘Forums’ menu item and click ‘New Forum’.
Now give your forum a title. For our example I’m going to use ‘New Restricted Forum’.
Then look over on the right side of your page for the box labelled ‘Restrict Content’.
Now click the dropdown and start typing to find the product you want to restrict the forum to. When you find it select it by clicking on the product name then publish the forum.
Your content restriction will be saved and the forum will be published. The only people that can see the forums beside users that have purchased the products are site administrators, editors and shop managers.
Currently custom messages are not available for bbPress forums.
Allows you to add/remove the allowed post types for the restricted content metaboxes. It is passed one variable which is the array of allowed post types. Default allowed post types are page, post, forum.
Only available in version 1.2.6 or above
Allows you to add the options to remove items from the My Account page or the Menu if the user hasn’t purchase the item.
Allows the user to filter the message that replaces the default bbPress message “You cannot reply to this topic”. It is passed one variable, which is the existing message. This filter can be found in the “inc/content-filters.php” file.
Lets you replace the default restricted content message where bbPress would normally show “Oh bother! No topics were found here!”. It is passed one variable which is the existing content restriction message. This filter can be found in the “inc/content-filters.php” file.
Lets you replace the default restricted content message where bbPress would normally show “You cannot create new topics at this time”. It is passed one variable which is the existing content restriction message. This filter can be found in the “inc/content-filters.php” file.
Lets you replace the default restricted content message where bbPress would normally show “You must be logged in to create new topics.”. It is passed one variable which is the existing content restriction message. This filter can be found in the “inc/content-filters.php” file.
Lets you change the default message provided for subscription products. The first variable passed is the existing message. The second variable passed is the product_id. This may be the product_id of a variation if it’s a variable subscription so make sure you test for that if you want to provide a custom message for a single variation.
Lets you change the default message for variable products. Remember that the $product_id passed may be the ID of the variation that the content is restricted by so you’ll need to test for that.
Lets you change the default message of a grouped product. $product_id may be the ID of a product inside the group so make sure you test for that and get the parent of the group as well if needed.
Lets you change the default message provide for simple products.
Lets you change the default restricted content message for the plugin. It is passed 2 variables. First it is passed $content which is the message. The second parameter is the $product_ids that the message would be saved with. This filter can be found in the “inc/content-filters.php” file.
wecr_bbp_forum_message_global and wecr_bbp_topic_message_global
This can be used to change the restricted message for forums in bbPress. If you’re using the plugin in a language outside of English this will let you detect your input text in your language and write your custom conditionals for your language so you can return the proper strings for restricted messages.
Recommended usage would be to copy the base functions (either topic_feedback_messages or forum_feedback_messages) and remove the filter at the end so you’re just returning your text.
There are currently no actions available for customization. If you think we need one, let me know.
Other Code Snippets
Currently nothing is here because we rolled the features in that used to be code only. WOOHOO!