How to Sell Access to Fields in Drupal 7

Submitted by Leighton Whiting on Tue, 01/17/2012 - 11:24

This tutorial picks up where How to Sell Access to Nodes in Drupal 7 leaves off. Please see that tutorial first for an overview of how to configure and set up Pay Per View.

The Premium Fields feature of Pay Per View is a really cool feature that is made possible by the new Fields API that is in Drupal 7. With this module, you can configure specific fields within a content-type to be protected, as opposed to the entire content type. This allows for fine-tuning the workflow and business model to fit your needs.

For our tutorial, we will demonstrate the ability to show a Low-Res image for free, and require the user to pay before they view the high-res image.

Setting up the Content Type

For our purposes we will create a new Content Type called 'Bio'.

10 Bio Content Type

Note that we don't need to even touch the MS PPV Settings fieldset on this page, because the Content Type isn't what we will be protecting.

Setting up the Fields

We will add two new fields for this content type, one for a low-res image and one for the regular size image.

11 Full-Res Image Field

12 Low Res Image Field

13 Low-Res Image Settings

As you can see, I restricted the dimensions of the Low-Res field to 50x50. Images uploaded to that field will be automatically resized. The hi-res field has no such restrictions.

Setting up the Display Settings for the Fields

To get the PPV Magic to happen, we need to set up some Display settings for the Fields. Go from the Manage Fields tab to the Display tab. From here, you can see the different 'display modes' that are available for this content type. It should have 'Teaser' and 'Default'. For our purposes, we are going to add a new Display Mode. We are going to enable the 'Full Content' mode.

14 Adding the Full Content Display Mode

Once this mode is enabled, switch to it. From here, we can set the 'Format' for the fields in the Full Content mode. We are going to leave all of it the same except for the 'Secret Image' field. We want it to use the MS PPV Display Formatter.

15 Selecting Display Formatter

16 Settings for the Display Formatter

Be sure to configure the settings for this display formatter for this field. You can specify how much the user should have to pay to access the Field, and when, if ever, it should expire. You can also add a protected content message if the user doesn't have access, along with any of the tokens that are there. Be sure to at least include the add to cart link token, or the users won't be able to purchase access to the field.

Testing it out

Now we are ready for a test. Let's create a Bio node first.

17 Creating the Node

18 Uploading the Images

Once the node is created, let's try to view it as a regular user.

19 No Access Yet

As you can see, the Secret Image field is protected, but the Low-Res field is showing. Let's try purchasing it.

20 Checkout

After we purchase the Field, we can now view the field without any problems! Success!

21 Access Granted

Conclusion

There are also many other things you can do with the Field Settings, Display Modes, and Display Formatters. This is just the tip of the iceberg. Experiment and let your business model be your guide.

One more thing to note is that the Pay Per View module allows you to override the field settings for individual nodes as well, so you can have a hi-res image on one node cost more than on another. It is really super-flexible, so you can get it just how you need it.

Enjoy!

Videos

I made these videos a while back but they are still mostly relevant today. I am posting them here for reference:

Selling Access to Field Groups using the Drupal Field Groups Module

Selling Access to Fields

Twitter Feed