Hi fellow drupal people.

I'm struggling, probably because i'm dense! but i thought what i wanted to do was really simple. heres the low down, i wanted my users to be able to purchase 30 days access to my site. for that 30 days any content they create would be published automatically. they could create content before this but it wouldn't be published - until they paid. once the 30 days is over there content would revert to unpublished.

I've got a product set up in ubercart that adds the users to a group call 'paid_members', i want to create a rule/trigger/action setup so the trigger is

'on run cron'

if node author is member of role 'paid_members'

then

action 'Publish content'.

The problem is that despite hours of trying i cant get this to work. I also want to do the reverse of this to unpublish a users content at the end of there subscription period. The reason that i dont want to use the trigger 'on content view' is that i dont want expired content to show in searches, only to have users click on it and then get page not displayed or cant be accessed. Same with publishing, dont want any users to have to click on anything to publish there content once they have paid. Also the bit that says "if node author is member of role 'paid_members'" i cant seem to select node author.
Any help or pointer would be greatly appriecated.

Thanks
jeff

Comments

drupalninja99’s picture

One approach would be to instead of publishing/unpublishing content view it a different way. Ubercart + uc_recurring is a great module and you can use roles as well to create a simple subscription system where when your subscription renews (like with authorize ARB) you keep your role, however if you cancel your role is removed and it all ties together. Through your site if you are pulling subscription content you can add a check in your code or views to only show content from the author if the author has a specific role. So in that way you're removing the content without actually having to unpublish it and ubercart handles it for you.

If you still really need to unpublish the content so that it is completely not visible you could create a _cron hook where you use a db query to pull all content from a user that does not have the role he's suppose to have and unpublish it then. It depends on what you're trying to do.

Garrett Albright’s picture

This is complicated enough that you should give up on trying to use rules and create a custom module instead. In fact, this all sounds fairly straightforward to do with some custom programming.

cntlscrut’s picture

Another way to handle this situation would be to create a "tie-in" module or extra set of code within an existing module that would apply 30-day cookie to the users that have paid for certain content.

with this you may implement hook_init() to test for the cookie on page load and then redirect the user to the content or if they're not a paying customer, to a landing page where they may apply/pay for the content.

the cookie method working along side user roles would be a closer solution to allowing a "real-time" solution for this based on usage statistics.

This would require some custom code to be written but, it would help to avoid the overhead and headache that would be required to get drupal actions or triggers to handle the situation.

moxwai’s picture

thanks very much for all your responses, some great stuff!
Thanks Jay - thats pretty much exactly what i want to do. I definately need the content to unpub as i dont want it to be viewable.. of course i could do that with roles and acl mod, but i thought publish/unpub would be much easier and also not sure if i can change acl's based on cron within rules - basically the same problem as pub/unpub. Problem with your suggestion is that i wouldnt be confident with coding that, not 100% sure what would be required, have Mssql exp and know a basic php, so understand the concepts but i think given the timeframe for my project its just not going to be possible.

Thanks garret, as per above i dont think your custom code option is going to work for me and was trying to stick within the drupal framework.

Geoff thanks for your comments thats certainly an option. Maybe be in touch.

Garrett Albright’s picture

Thanks garret, as per above i dont think your custom code option is going to work for me and was trying to stick within the drupal framework.

Creating a custom module is inside the Drupal framework. Drupal is a CMS with lots of first- and third-party features, but it's also a development platform so that developers can easily add their own functionality. Actions and Rules and such are pretty limited in what they can do, and you're hitting those functionality limits at the moment. It's time to code (or hire someone to code for you).

moxwai’s picture

has anyone tried this with workflow-ng? (now workflow) i'm just playing with that now and it looks like i may be able to trigger a workflow state based on cron with rules module. Whether pub/unpub is one of those remains to be seen... would be nice - any comments appreciated. Thanks again for all your feedback tis nice to have some support:)

drupalninja99’s picture

I guess I don't get how you would plan to use workflow to accomplish what you're trying to do.

moxwai’s picture

Thanks again for the comments there people. I guess its time to find someone that can code this. Cheers J

moxwai’s picture

Thanks again for the comments there people. I guess its time to find someone that can code this. Cheers J