4

I was able to set rule to unpublished after +30 days. But I would like to tweak my rule to give to my users the possibility to choose between posting for 2 weeks, one month or 3 months.

So, I guess that there would be an "if choice X, than unpublish after Y period of time". Can the field (to choose duration) be a text dropdown?

Can this be done without PHP? If so how?


So, I figured out that I can add a condition like this :

Parameter: Data to compare: [node:field-time-limit], Data value: 2 weeks

But since I have 3 choices for my ads (2 weeks, 1 month, 3 months), does this means that I have to make 3 different rules, one for each time limit? (it seems to make sense, but I'm not shure).

Note: I'm aware of the thread about "Tutorial 2: Publish content exactly 24 hours after it was created".

3
  • Yes, its possible through Rules Module (php code not needed) according to your requirment
    – Anaz
    Commented Jan 13, 2016 at 6:46
  • You can use rules module for this action, Refer : drupal.org/node/517674
    – Anu Mathew
    Commented Jan 13, 2016 at 6:48
  • Thanks... So now I know that I dont need PHP (I know nothing about that)!. So I'll keep digging...
    – user54770
    Commented Jan 13, 2016 at 14:12

1 Answer 1

1

Your question seems to exist of actually 2 questions, so here are 2 parts of an answer to address each of them (I'm assuming this question is about D7).

Part 1

Refer to my answer to "How to specify a Rules condition related to select list values?" for an example Rule (in Rules export format) that allows for specifying a Rules condition related to a specific value selected via a selection list.

With this (and some minor tuning of that sample to fit your field and values), you have an answer to your "if choice X, than unpublish after Y period of time".

Part 2

Refer to my answer to "Redirect users with specified roles to specified term pages", which shows how you can redirect to various URLs (depending on some role). It also explains 2 possible approaches for either creating multiple rules (1 for each role) versus just 1 rule (by using the Conditional Rules module).

With this (and some minor tuning of that sample to fit your case here), you have an answer to your "does this mean that I have to make 3 different rules, one for each time limit". The actual answer is: either way can work (personally I'd go for just 1 rule, using the Conditional Rules module).

PS: So yes this can be done without PHP, it only requires some site building using the Admin UI for Rules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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