Pippins Plugins
  • Email
  • Facebook
  • Feedburner
  • Github
  • Google
  • Twitter
  • Vimeo
  • Youtube
  • Rss
  • About
  • News
  • Join the Site
    • Member Benefits
    • Member Plugins
    • Email Notifications
  • Plugin Store
    • Affiliate Area
    • Checkout
  • Plugins
    • Plugin Portfolio
      • Plugin Portfolio – List View
    • Free
    • Premium
    • Member Plugins
    • Coding Standards
    • Get Plugin Support
  • Tutorials
    • Series
      • Plugin Development 101
      • Creating a User Follow System Plugin
      • Customizing Restrict Content Pro
      • Displaying Content with Easy Content Types
      • Writing Your First WordPress Plugins, Basic to Advanced
      • Working with Widgets
      • User Submitted Image Galleries
      • Plugin Thoughts
      • Integrating Stripe.com with WordPress
      • WordPress Rewrite API
    • Member Exclusive
      • Free Members
      • Subscriber Only
    • Difficulty
      • Beginner
      • Intermediate
      • Advanced
    • Action and Filter Hooks
    • Ajax
    • Custom Post Types
    • External APIs
    • Short Codes
    • Taxonomies
    • Video Tutorials
    • Widget Tutorials
    • WordPress Admin / Dashboard
    • Working with jQuery
    • WordPress Database
    • Writing Plugins
    • Tag Index
  • Reviews
  • Support Forum
  • Contact
    • Support the Site
    • Request Code Review
    • Plugin Support

Build an À la Carte Premium Tutorial Shop

Posted on July 11, 2012 by Pippin in Intermediate, Tutorials 9 Comments
Home» Tutorials » Intermediate » Build an À la Carte Premium Tutorial Shop
content-restriction-image
Tweet
Love It - 1

There are a lot of premium membership tutorial sites out there, this one included, and they usually require that memberships purchase a subscription to the site in order to access the premium content. In this tutorial, I’m going to walk you through the process pf creating an À la Carte tutorial site that lets users purchase access to only the tutorials they want.

This tutorial will be a bit different than what I usually do, as I’m going to be mostly walking you through the setup of a plugin, rather than how to write it from scratch.

We will be using Easy Digital Downloads to power our tutorial store. If you are not familiar with EDD, it is an ecommerce plugin I have written (with the help of several other developers) for selling digital products. You might be asking why we would use a downloads plugin for selling tutorials, and the answer is simple: EDD is extremely flexible and provides everything we need, so with just some minor tweaking, we can turn it into a Tutorial Access plugin.

Along with EDD, we will also be using the Content Restriction add-on. This extension is a $29 add-on (the main EDD plugin is free), so you will need to purchase it to be able to setup the system described in this tutorial. If you are a premium member on this site, then you have access to a 50% off discount code, listed below. If you’d like to save 50% on the Content Restriction add-on, then Join the Site today and you will see the discount code when you come back to this post.

Once you have both Easy Digital Downloads and the Content restriction add-on installed, you are ready to get started.

The way that we will setup the À la Carte shop is by having tutorials (regular Posts) that have their content hidden by a short code, and then a separate EDD product that defines the pricing for the tutorial. A button to purchase access will be placed at the bottom of each tutorial with a second short code.

Before we jump into our content creation, let’s first look at doing some minor tweaks to the EDD plugin. By default, EDD includes a lot of product options that have no use in this scenario, so we are going to remove them. We are also going to rename “Downloads” to “Tutorials”.

The code below will allow us to make the tweaks to the EDD product options, and you can place it in your functions.php or your own custom plugin (recommended).

Changing “Downloads” to “Tutorials”

1
2
3
4
5
6
7
8
9
10
define('EDD_SLUG', 'product'); // changes the post type slug
 
function pw_edd_labels( $labels ) {
	$labels = array(
	   'singular' => __('Tutorial','wmb'),
	   'plural' => __('Tutorials','wmb')
	);
	return $labels;
}
add_filter('edd_default_downloads_name', 'pw_edd_labels');

Once this snippet is active, the menu that previously said “Downloads”, will now say “Tutorials”, as will all other instances of the download label throughout the plugin.

Removing Unneeded Product Options

The default product configuration page in EDD looks like this:


and this:

We really don’t need all of these options. The only ones we need are:

  • Title
  • Categories (maybe)
  • Tags (maybe)
  • Price
  • Purchase Log

We will now remove the options we don’t need.

First we will modify the attributes that the product post type supports. For this scenario, we only need a title:

1
2
3
4
function pw_edd_post_type_supports( $supports ) {
	return array('title');
}
add_filter('edd_download_supports', 'pw_edd_post_type_supports');

Next we will remove the “Download Log” meta box, since our tutorials do not have downloadable files (though you could if you wanted to include source files with the tutorials):

1
2
3
4
function pw_remove_edd_metaboxes() {
	remove_meta_box('edd_file_download_log', 'download', 'normal');
}
add_action('add_meta_boxes', 'pw_remove_edd_metaboxes', 999);

Lastly, we will remove unneeded options from the main Download Configuration meta box:

1
2
3
4
5
6
7
8
9
function pw_remove_product_options() {
	remove_action('edd_meta_box_fields', 'edd_render_files_field', 20);	
	remove_action('edd_meta_box_fields', 'edd_render_purchase_text_field', 30);	
	remove_action('edd_meta_box_fields', 'edd_render_link_styles', 40);	
	remove_action('edd_meta_box_fields', 'edd_render_button_color', 50);	
	remove_action('edd_meta_box_fields', 'edd_render_disable_button',60);	
	remove_action('edd_meta_box_fields', 'edd_render_meta_notes',70);	
}
add_action('admin_init', 'pw_remove_product_options');

Our Tutorial product configuration is now greatly simplified and looks like this:

We can now start setting up our content.

There are two steps to adding an À la Carte tutorial:

  1. Create the Tutorial product, which defines the access price
  2. Create the Post with the tutorial content

When you create a Tutorial product, simply give it a title (probably the name of your post, or similar), set a price, and optionally define categories and tags. That’s it; the bulk of the content for a tutorial is defined in the post.

The key to creating À la Carte tutorials is restricting the content of the tutorial to only those users that have purchased, and this ability is provided by the Content Restriction add-on.

The Content Restriction add-on will give you two methods for restricting content to buyers:

  1. A short code, [edd_restrict], to restrict portions of content
  2. A meta box option to restrict the entire content

We are going to use the short code for this tutorial. If you want to use the meta box option, then you will need to tweak your template files a little bit in order to show the Purchase Access button. If you are an advanced user who is comfortable doing this, then I recommend the meta box option as it is a little bit easier and more efficient.

The short code provided by the Content Restriction add-on is quite simple to use. It accepts two main parameters:

  • id – the ID of the product we are requiring users to have purchased
  • message – the text to show to users who have not purchased access

There is a third parameter called “price_id” for users who wish to use EDD’s variable pricing system. Consult the add-on documentation if you are interested in this.

When you create your tutorial posts, you will use the [edd_restrict] short code to hide the portion of the content that want users to be required to purchase, and you will do it like this:

[edd_restrict id="#" message="You must purchase access to view the rest of this content."]This content is restricted.[/edd_restrict]

The # is replaced with the ID number of your Tutorial product.

This will result in the following:

Once a user has purchased access, they will see the entire contents of the post.

Now we just need to place the Purchase Access button at the bottom of our post. To do this, we will use the [purchase_link] short code provided by EDD. You can find the exact short code to use on the Tutorials page:

You can also use the short code generator button located in the Upload/Insert section of the editor:

Your purchase link short code, once created, will look like this:


Once placed at the bottom of your tutorial post content, you will have something like this:

When a user wants to purchase access, they simply click on the button, go to the checkout page, complete the purchase, and that’s it! They now have complete access to the tutorial contents.

It depends on the theme you’re using, but the basic checkout page (provided by EDD) will look like this:

Some Notes

The above system that I have walked you through can be setup in less than 10 minutes and works very, very well, but there are a few things you should take note of:

1. Users must be logged-in in order to view the restricted content. I recommend you requires users have an account to purchase access. You can easily turn on this restriction in EDD by going to Tutorials (or Downloads) > Settings > Misc and check the box to Disable Guest Checkout and the box for Show Register / Login Forms.

2. You will need to go through basic Easy Digital Downloads setup. This includes setting a page to act as the checkout page, a purchase success page, and possibly a purchase history page. These only take a moment to setup and are described in the Installation and Basic Setup documentation pages.

3. Since users are required to be logged-in, you can show a login form with [edd_login].

Download EDD Purchase Content Restriction

Tweet Follow @pippinsplugins
easy digital downloads

9 comments on “Build an À la Carte Premium Tutorial Shop”

  1. Meir Bar-Tal says:
    July 16, 2012 at 3:15 am

    Hey Pippin,
    Great post!
    Remark: the Content Restriction link is invalid (you’ve appended the URL to your domain as root)
    Cheers! :-)

    Reply
  2. Pippin says:
    July 16, 2012 at 9:19 am

    Thanks for the catch! It’s been fixed.

    Reply
  3. designbyniall says:
    July 27, 2012 at 6:31 pm

    Awesome! I’ve been thinking of starting a site for some more advance tutorials (with the more basic ones free). This will really help as I don’t have time for something custom. Thanks a lot!

    Reply
  4. esadmin says:
    November 4, 2012 at 10:17 pm

    This looks like it could work for us – EDD is another impressive piece of software from the Pippin team. A couple questions:

    1. Does the EDD “Download Link Expiration” setting have an effect here – would that be the way to give users access to the tutorial for a specific period of time? We want to sell access to content by the month.

    2. Similarly, does the EDD “Disable Redownload” option do anything when the CR addon is displaying the content?

    3. How about “Disable Guest Checkout” – if the user is logged out of the site but they bookmark the page that the CR content is on, can they still view the content?

    4. Finally, are bundles possible with this setup? Doesn’t seem like it but maybe I’m missing something. It looks like each tutorial need to be managed as its own Tutorial (aka EDD “Download”) product and users must purchase them individually, correct? Any ideas for this type of packaging? (Buy 3 at 50% off or whatever)

    Thanks in advance for any help.

    Reply
    • Pippin says:
      November 5, 2012 at 8:35 am

      1. No, the expiration has no effect here.

      2. No it does not.

      3. No, users are always required to be logged in to verify that they can view the content.

      4. You can create a bundle by categorizing the products and then using [purchase_collection] short code. I can give you more information on this if you’d like, though it does not automatically discount the amount.

  5. Sam says:
    January 10, 2013 at 5:53 pm

    I bought your Restrict Content Pro plugin and found out it wasn’t really what I needed, so I ended up buying this one too :X

    So far it’s working rather well for what I need, but as I need to modify it a bit, I had a couple questions. I hope that’s okay?

    1. Is there any way to ‘hide’ the purchase button if the user has already paid for the post? Right now, it comes up regardless.

    2. I really need access to restricted content to expire after x amount of days (and the time frames will vary post-to-post), so I plan to get my hands dirty with that modification; ideally the expiration will work just like your “Restrict Content Pro”. I know this is probably far too involved to expect any snippets, but if you had any advice on the best way to do this, or anything to point me toward, or even vagueish encouragement, that would be lovely!

    3. It’d be awesome if links to the purchased content could be included in the purchase and download history, and also the emails and receipts as well. In my case, we’re not promoting the restricted posts on the front-end at all, just the product grid, so there’s no way for the user to find the restricted content once they’ve purchased it. I figure maybe just adding an extra meta field for Download?

    (Sorry for the long comment; I would have made a support ticket or forum post, but this add-on wasn’t listed as a product option).

    Thanks in advance!

    Reply
    • Pippin says:
      January 10, 2013 at 9:53 pm

      1. There is with a small amount of PHP. Are you comfortable with that?

      2. Not out of the box, sorry. It’s not too difficult to do with a couple of custom PHP functions, so let me know, as with 1, if you’re comfortable with that.

      3. Are you selling any actual file downloads or just the content?

    • Sam says:
      January 11, 2013 at 3:05 am

      1 and 2. Yes, totally comfortable with PHP!

      3. Just the content, no actual downloads. But like, for instance, right now when a user purchases an item, the Purchase History shows the item, and below it says, “No downloadable files found.” Screenshot: http://oi48.tinypic.com/359ya1u.jpg

      Ideally, instead of that, it would link the user to the page they purchased access to.

      Thanks so much for the reply!

    • Pippin says:
      January 14, 2013 at 9:18 pm

      1. This should do the trick: https://gist.github.com/4535753

      2. This one I need to think on a bit.

      3. Have you ever used the Posts 2 Post plugin?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Login

Lost your password?

Please enter your username or e-mail address. You will receive a new password via e-mail.

  • Facebook Become a Fan Like

  • Twitter Subscribe on Twitter Follow

  • YouTube Follow my Videos Subscribe

  • RSS Feed Subscribe with RSS Subscribe

Easy Digital Downloads

Most Loved

  • Love It Pro for WordPress
  • Write a “Love It” Plugin with Ajax to Let Users Love Their Favorite Posts / Pages
  • Simple Notices Pro Plugin for WordPress
  • User Bookmarks for WordPress
  • Front End Registration and Login Forms Plugin

Similar Plugins and Posts

  • Restrict Content Pro – Member Discounts for Easy Digital Downloads
  • Easy Digital Downloads – One Year Old
  • Easy Digital Downloads v1.5 Released
  • Crucial Security Flaw Discovered and Fixed
  • Easy Digital Downloads Giveaway

Latest Premium Content

  • Plugin Development 101 – Introduction to Adding Dashboard Menus
  • Plugin Development 101 – Intro to Loading Scripts and Styles
  • User Follow System – Part 5
  • Plugin Development 101 – Intro to Short Codes
  • Plugin Development 101 – Registering a Custom Post Type
  • Plugin Development 101 – Intro to Actions

Latest Tutorials

  • Submitting Your First Pull Request to a WordPress Plugin on Github (1)

    Github is an extremely popular tool for managing WordPress plugins, and one...

  • Plugin Development 101 – Introduction to Adding Dashboard Menus (1)

    Adding new menus, both top level and sub level, to the WordPress Dashboard is a really common task for plugins...

  • Plugin Development 101 – Intro to Loading Scripts and Styles (16)

    In this part of Plugin...

Enter your email to receive automated updates when new posts are published

Latest Tweets

  • @ghost1227 tried that. I&#039;ve been outside cleaning gutters most of the day
    May 18, 2013
  • RT @chris_olbekson: In 3 years your site will still be running jQuery 1.9 while WordPress is running 2.4. Don’t de register built in jQuery
    May 18, 2013
  • RT @chris_olbekson: As @kovshenin just reminded me, as of 3.6 you will no longer be able to de register WordPress built in jQuery #WCATX
    May 18, 2013

Topics

contextual help add_shortcode meta box Tom McFarlin add_options_page Rémi Corson wp_enqueue_script featured get_user_meta attachments shortcodes register_setting Sugar Event Calendar attachment mail chimp image plugin forms login short codes authors Related posts do_action bbpress comments recent posts post types apply_filters short code taxonomies custom post type images gallery Ajax Stripe taxonomy jquery users widgets add_filter easy content types add_action widget restrict content pro easy digital downloads

Weekly Newsletter

Useful Links

  • Join the Site
  • Plugin Store
  • Affiliate Area
  • Tag Index
  • Support the Site
  • Suggest a Tutorial
  • Random Post
  • Contact

Monthly Archives

(c) 2011 Pippin's Plugins