Is there a way to use Ubercart to restrict view access to a node until they pay? I am using the Quiz Module and want to force users to pay to take a quiz.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | zerooption.patch | 501 bytes | jeremy.zerr |
Is there a way to use Ubercart to restrict view access to a node until they pay? I am using the Quiz Module and want to force users to pay to take a quiz.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | zerooption.patch | 501 bytes | jeremy.zerr |
Comments
Comment #1
jeremy.zerr commentedYou can use the uc_node_access module: http://drupal.org/project/uc_node_access
When you create a product, you add the Node Access as a product feature, and point it to your node that you want someone to get access to.
The node access will be granted when the purchase has been completed, and the order status moves into a "complete" state.
Jeremy Zerr - http://www.zerrtech.com
Comment #2
mdowsett commentedthx for the quick response. I don't have much experience with UC yet (I'm an eCommerce convert) but I tried adding the 'quiz' content type as a Product Class but since the 'quiz' content type was created by the Quiz module, I get this error:
"This is a node type provided by another module. Only custom node types may become product classes."
So it looks like I can't add a non-custom-node type as a product. Is that a correct statement? If so, it's a road-block for me.
Comment #3
jeremy.zerr commentedHere are some steps to follow which will help explain how this all works in Ubercart after you have installed the uc_node_access mod and its dependencies.
1) Edit the Access Control settings for Content Type Quiz
a. select the checkbox for "Enable per content node access control settings".
2) Create a Quiz node
3) Create an ubercart product and save it
4) for that product you just saved, go to the Features section, add a Node Access feature, select your Quiz node you created in 2
So when the product is purchased, the user will be added to the "per content node access" list for that Quiz node.
Jeremy Zerr - http://www.zerrtech.com
Comment #4
tr commentedMoving to the uc_node_access queue ... please mark as "fixed" if #3 solved your problem.
Comment #5
mdowsett commentedalmost fixed (great tips). When creating Node Access rules for a product, I am getting this error message prior to completing the node access rules:
"The node access handler is either not specified or missing"
it doesn't give any tips or links to point me in the right direction to resolve this
Comment #6
jeremy.zerr commentedPlease make sure that you enable the module UC Node Access ACL that is a helper module that comes with uc_node_access. That should define the node access handler to use.
Then afterwards, if you haven't done so already, you might also have to Rebuild permissions by going to Content Management | Post Settings (admin/content/node-settings).
I think that is all that is needed, but let me know if not, I have sites that are set up using this, but don't remember all the steps from a fresh install.
Jeremy Zerr - http://www.zerrtech.com
Comment #7
mdowsett commented...not working....I'm at a loss. I've done all you've said in all of your posts.
I placed an order for the product and set it to be paid by COD. As expected, that user did NOT have access to the associated quiz - since they didn't pay.
However, as admin, I went thru and marked their order as paid...and still no access. I checked the per role access to the quiz and that user wasn't listed. I went and manually added that user to the view access control list so they should be able to have access to that quiz but that user still can't access it.
That leads me to believe the ACL isn't working right....and I did rebuild permissions yet again and still no go.
Any ideas?
Comment #8
mdowsett commentedI gave the 'view quiz' permission to the authenticated role...but of course they then get access to all the quizes (without paying).
I'm lost
Comment #9
mdowsett commentedah....I think I found something. I checked the log and found the uc_node_access entry saying that the user will be given access tomorrow. I noticed before that in the settings that access is only given at a minimum of 1 day.
I thought that was rather long...in this day-and-age, noone wants/expects to wait that long when they pay for something! :) Is there a way to fix that so access is granted immediately on payment completion?
(I still have a feeling that it won't work...since adding the user manually didn't work either)
Comment #10
jeremy.zerr commentedWithin the Node Access product feature settings, set the access time delay to 0 days. Sounds like you possibly have it set to 1 day. I have mine set to 0 days and people get access as soon as payment completes.
Jeremy Zerr - http://www.zerrtech.com
Comment #11
mdowsett commentedyeah...still no access after 24 hours.
And my numeric list of options for the times goes from 1-52....no option to choose 0
Comment #12
jeremy.zerr commentedHere is the single line patch for that puts in the 0 option. Didn't realize that was something that I coded in myself until I took a look at the current dev snapshot.
Comment #13
jeremy.zerr commentedI also just went through and successfully created a quiz node, and had a user go through and purchase it, and the node access all worked perfectly.
Here are some other tips.
1. Make sure you give authenticated users the Access Quiz permission on the User Management | Permissions page. Don't worry, the content access overrides this so all authenticated users don't really get access because of what we do in step 2.
2. With the quiz node you are planning on selling, go into its Access Control settings, and uncheck all role-based access. Due to the nature of selling the quiz as a product, you don't want to do role-based permissions, looking to do user-based permissions.
Then go and set the access to 0 days using the previous patch.
Purchase product, then view quiz node successfully. This worked for me.
As an intermediate testing step, go add a user manually to the access for the quiz node you are trying to sell. Sounds like you know how to do that. That really should cause it to work. Maybe it didn't work before because you didn't have the Access Quiz permissions set for Authenticated Users.
After you purchase the product, you should see that user entered into the user Grant View access for the quiz node.
I don't know what payment gateway that you are using, but it might be good to initially use credit cards and the Test Gateway to get it working. I'm not sure if there may be any unexpected interactions with other payment gateways.
Hopefully this will do the trick for you.
Comment #14
jeremy.zerr commentedOops, wiping out a mistaken double post.
Comment #15
mdowsett commented[quote]2. With the quiz node you are planning on selling, go into its Access Control settings, and uncheck all role-based access. Due to the nature of selling the quiz as a product, you don't want to do role-based permissions, looking to do user-based permissions.[/quote]
Do I uncheck the 'view any content' for anon and auth roles as well? or just custom roles?
I unchecked them for anon and auth users and now in the view I made that lists the Quizes, that quiz isn't shown to the authenticated user.
That may not be a show-stopper/bad thing....just thought I'd ask.
I'll test the rest later.
Thanks SO MUCH for the tips. Let's hope it works.
Comment #16
mdowsett commented...I think it worked....(initial testing anyways).
MANY MANY thanks. Not many modules seem to have such prompt support. I appreciate sticking with me to find a solution
Comment #17
jeremy.zerr commentedThe learning curve can be pretty steep and hard to climb sometimes without a guide, glad I could help.
Your question:
Do I uncheck the 'view any content' for anon and auth roles as well? or just custom roles?
Depends on how you are using it.
I have a situation where a client has paying members (in a custom role) that he creates members-only videos for, but he also wants to be able to sell those same videos one at a time without someone needing to pay for a full membership. So the setup for each video is as a single node, where the members-only role (whether you use Authenticated users or some other custom role) has 'view any content' for that node. The access control is additive, so the video would be accessible by members in that role and anyone who purchases it as their username would be attached to the Grant View Access list.
If you give the authenticated user role 'view any content' access to that Quiz, then anyone who has an account will be able to access it without specifically purchasing it, if you have other products you are selling that might cause a problem since an account is created upon purchase. But I think your question might come from you looking for a good way to present that purchased quiz to the user after they buy it so they can find it easy. The permission controls in place will prevent a link to the node from showing up if you don't have access to it. The method I would recommend using is to make a Views block that shows titles/links to all nodes of content type Quiz. That block will only show a link to Quizzes the user has access to by purchasing it.
Comment #18
mdowsett commentedthx for all your explanations
Comment #19
blksheep commentedHi,
I'm stuck with the same issue here and I've not been able to go past 2 things:
1- The error: "The node access handler is either not specified or missing. Node access features can be added to products but cannot be processed until this is resolved." when creating the product feature for "node access" --- there was no clarification on how this was solved :( Enabling the UC Node Access ACL as suggested above did not work to remove the error.
What was the expected outcome of enabling this module? A new field in the "product feature"? I could not find in the whole Internet a more detailed explanation on this error...could you help?
2.- Maybe because of the above error, I just can't make the per node access permission to be assigned on checkout/payment...only if I add it manually works...
Any pointers would be very appreciated.
Thanks!
Comment #20
jeremy.zerr commentedMake sure you have Content Access and ACL modules enabled.
Look under the Administration section, follow this navigation:
Store Administration | Configuration | Product Settings | Product Features | Node Access Settings
You need to select an access handler if you haven't. Hopefully this will allow you to see more into what might be wrong.
- Jeremy Zerr
Comment #21
blksheep commentedHi Jeremy,
That did it for me! It was not clear where to find the setting to add the "access handler" -- The path to the menu was all I needed. It might be good to include that in some documentation.
Thanks!! Very grateful for the prompt response!
Comment #22
jklcom99 commentedI'm trying to do something very similar with a slightly different twist.
Here's my use case:
1) The site will have a reviewer to create the original content with some write up about a particular store
2) There will be two types of users (owner of a store & normal user), normal user can comment on any store, owner can edit & upload files to his/her store but cannot change any comments
3) Owners will need to purchase a subscription in order to be able to edit/update their own node
My problem is I don't know how to distinguish if a registered user is a normal user or a owner, and how to link the registered owner to his/her content node
Can you give me some pointers?
Thank you
Comment #23
jeremy.zerr commented@jklcom99
Please start a new issue in the uc_node_access issue queue if you would like to get some help. I have some ideas to help you, but this thread is closed and is for a different issue.
Thanks, Jeremy
Comment #24
billbeloe commentedHi,
I'm trying to use this to charge for access to a quiz for a client, have followed every instruction I can find on the internet & then played around with every setting I can find & appear to be so close to getting this working, but alas with no avail!
I have the following modules enabled: ACL 6.x-1.3, Content Access 6.x-1.2, UC Node Access 6.x-1.x-dev, UC Node Access ACL 6.x-1.x-dev, Ubercart 6.x-2.4
(I was also using node_access 6.x-1.3, but disabled this module to try to get things working, but it didn't appear to make any difference.)
I have set /admin/user/permissions to allow anonymous / authenticated users to allow quiz access (tried removing access to all users here but this didn't help)
I have been to: /admin/content/node-type/quiz/access and unchecked all of the boxes except Enable per content node access control settings which is checked. I have also set the priority to 10 under advanced.
I have checked /admin/store/settings/products/edit/features and found that ACL/Content access is selected in the node access settings
I have created the quiz
I have created a product (with a price of £0 for testing), gone to features > node access selected the relevant sku and the node id of the quiz, then selected 0 days delay and indefinite access.
I have then logged in as a test user, purchased the product and then tried going to the quiz but I get an access denied error!
I have noticed that if I go to the quiz logged in as admin and go to the edit > access control tab, the test user is already listed under the "grant view access" list as I would have hoped.
If I change nothing on this page and simply submit the form then everything seems to work fine, the test user can access the quiz fine as expected. obviously this process needs to be automated, I can't be going in to the edit quiz page & submitting this form manually every time someone purchases access!
If anyone can give me any pointers as to where I am going wrong, I would be really appreciative !
Many Thanks!
Bill
Comment #25
bartezz commentedGreat info Jeremy!
Subscribing!
Comment #26
webservant316 commentedsubscribing - I am struggling to get uc_node_access working as well.
edit - I have got it working now. I use uc_node_access with content_access. I also use taxonomy_access, but for controlling access to the terms, not the nodes.
Comment #27
Marena commentedHi,
don't know if anybody is still interested in the solution for the issue described in #24, but this worked for me(i'm still testing, but seems to work fine):
go to the "handlers" directory in uc_node_access, open uc_node_access_acl.module and change
acl_node_add_acl($nid, $acl_id, TRUE, FALSE, FALSE);
to:
acl_node_add_acl($nid, $acl_id, TRUE, FALSE, FALSE,1);
this line sets also the priority for the particular acl_id... Without the priority set, it won't work...You can set it to 1 or any number above 0,
Hope this helps
Comment #28
parmenides commentedI'm looking to do the same thing as the OP (use the Quiz module and charge users for access to quizzes). Is there any way to do this without using the UC Node Access module? I ask because I'm using Drupal 7.