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.

  1. Basic Setup
  2. Restricting pages
  3. Restricting Forums
  4. Filters
  5. Actions
  6. Other Code Snippets

If you still have questions about how to use the plugin shoot me an email at support@sfndesign.ca.

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.

Download Link and License Key

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.

Plugins / Add New

Then select ‘Upload’ and use the file choose dialogue to choose the .zip file you were provided with.

upload-choose-file 14-07-14, 3.33.42 PM

Once the plugin is uploaded choose ‘Activate Plugin’.

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.

SFN License 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.

save and activate

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.

in-post-page-restrict-box 14-06-26, 4.08.34 PM

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.

Shiny new remove from My Account button

If you’d like to add a custom message to the page then you’ll need to look at the ‘Custom Restricted Message’ box.

custom-restricted-message

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’.

new bbpress 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’.

content restriction box on bbPress forums

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.

Filters

wecr_allowed_post_types

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.

wecr_allowed_meta_post_types

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.

wecr_restricted_content_message_cant_reply

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.

wecr_restricted_content_message_no_topics_found

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.

wecr_restricted_content_message_cant_create_topics

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.

wecr_restricted_content_message_logged_in_create_topics

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.

wecr_subscription_message

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.

wecr_variable_product_message

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.

wecr_grouped_product_message

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.

wecr_simple_product_message

Lets you change the default message provide for simple products.

wecr_restricted_content_message_global

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.

Actions

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!

Posted by Curtis McHale

Web developer specializing in membership and ecommerce sites. I like to ride my bicycle.