1

Relevant modules installed:

What I have tried:

  • Rule 1: activates on user login that displays a system message.
  • Rule 2: activates on Webform submission with the condition that the Webform's name is the required name. The rule executes PHP code to disable Rule 1 if true.
/**
* Implements hook_update_N().
* Disables name_of_rule rule.
*/
function hook_update_N() {
  $rules_config = rules_config_load('name_of_rule');
  $rules_config->active = FALSE;
  $rules_config->save();
}

However, this set of rules is NOT working at the moment.

Concerns:

  • If Rule 1 was working, how do I ensure that it permanently disables Rule 1 per user, and not globally?
  • Is there a better way to do this?
  • For example, all I should need is one rule: On user login + if a Webform has not been filled out, display a message. However, I have not been able to find a module that adds the "If Webform has not been filled out" rule.

2 Answers 2

0

Referring to your "is there a better way to do this": not sure if you'll consider it "better", but this is how I would adapt your 2 rules to actually "display a message on login until a user fills out a Webform" (as in the title of your question):

  • in your Rule 2, I'd use an Action to "flag" the user, using the Flag module, with a (none-global) flag named something like "Webform OK" (and "Webform not OK" as the alternative). By the way, the nature of such flag is that it is for each user individually.

  • in your Rule 1, add a Condition like "Is this user NOT flagged (with the Webform OK flag)".

With these 2 corrections of your 2 rules, and by adding the Flag module to your mix, you can:

  • probably simplify both rules, such as removing the (potentially dangerous?) PHP code in your Rule 2.
  • possibly eliminate the "Conditional rules" module.
2
  • Thanks for the reply, that sounds more elegant than writing a quick custom module to do this which is what I was about to resort to... I'll give this a try later in the week!
    – sdemurjian
    Commented Sep 16, 2015 at 20:03
  • Thanks for the feedback. Are you familiar with the Flag module? Or should I add a few pointers to recommended video tutorials to my answer? Commented Sep 16, 2015 at 20:06
1

I think the module you are looking for is 'Rules Webform Submitted'.

This module is similar to Webform Rules in that it supports integration between Webform and Rules, but different in that Webform Rules supports the Event "Webform Submitted", while Rules Webform Submitted provides a Condition which is typically triggered by a Node Event.

So, you can use the event 'On user login' and the condition that 'Rules Webform Submitted' offers to create your rule.

1
  • Forgot to mention I looked into this module, but it doesn't have a version for Drupal 7
    – sdemurjian
    Commented Sep 17, 2015 at 21:01

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.