How to unpublish postings according to the value of a field? 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".
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.