0

I am setting up a site for a web series. I would like to setup the site so that members can only stream an episode if they have already paid for it. We are using Vimeo PRO to serve our videos, and are using Video Embed Field to display the videos on the site.

If the member has not paid to stream this video, I would like to display a field other than the one with the embed code -- likely a field containing either a banner or a trailer for the show.

I found a video that somewhat outlines how to do this on a node-by-node basis, but I need to restrict access to just a field within the node, and not the entire node.

Is there an optimal way to set up this workflow?

1

I ended up doing node-based permissions instead of field-based. To set it up, I followed the instruction in the video I linked to originally. I simply created content types for SD and HD streams, and am granting access by user to those. I'm probably going to create a view that will go on my original node that displays if the user has the correct permissions.

|improve this answer|||||
0

I'm sure there are other ways to do this but one way to tackle it would be in the theme layer. You could create a custom template for this particular content type, and within the template you could hide the full video field or the teaser video field as needed. For example, in node--video.tpl.php if your content type was named video, you could set up an if/then to check whether the user has permission to view the video (if you have a permission that works here, in a custom module for example):

if (user_access('view member videos')) {
  hide($content['field_video_teaser']);
} else {
  hide($content['field_video']);
}

If you don't have a special permission to check you could check the role, although it is usually preferred to use permissions rather than roles to be more flexible. That would look like this:

global $user;
if (in_array('member', $user->roles) {
  hide($content['field_video_teaser']);
} else {
  hide($content['field_video']);
}
|improve this answer|||||
  • I get that I could use a template to determine which field is displayed. What I don't know, I guess, is how to set permission to view the video on an episode-by-episode basis. I don't need to give access to the content type. We have 180 videos, so with this method I would need 180 roles? I guess my best option is to set a multi-value field in user profiles and populate it with an nid when an episode is purchased. Then when a video node is viewed, I'd check if the nid is in the array of the user's purchases, and use that to determine if the video should display. Does that sound accurate? – Mrweiner Nov 5 '14 at 23:04
  • 1
    Gotcha, I was thinking you had an all-you-can-eat membership, not a per-video purchase. In that case, I recommend you start here and do some devel testing to see what kind of permissions are set within the node regarding file access (even though you are using it as a Vimeo stream rather than a file download): drupal.org/project/commerce_file – Laryn - CEDC.org Nov 5 '14 at 23:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.