0

I am creating a simple internal ticketing system which emails customers when the status of their ticket changes (Open -> Waiting on parts). I have set up rules to do this and I haven't had any issues with it. However, I would like to create a way for customers to "unsubscribe" from the emails. I have created a checkbox field named "allow emails" which determines if customers will or will not get an email as a condition for the rule.

I would also like to include a link at the end that if clicked the customer would set the field to "no" or "off".

Note:Customers aren't actual users on the site but are nodes within a "customer" content type. The users are our internal staff that would log in to use the website.

Can rules do this by itself or do I need a separate module?

Thanks

1

I'm not sure I understand exactly what you need, but the great module Rules Link (https://www.drupal.org/project/rules_link) provides a link that can be attached to any content type or entity, and can also be accessed in Views as a special Rules Link field. When you click the link a preset Rule is triggered. The link passes the node or entity as a parameter to the Rule. There is also the option of using a "Javascript" link that invokes the Rule via AJAX (without reloading the whole node) - I've never used that option, but I suspect that it may help your needs.

4
  • Basically I would like to create an "unsubscribe" URL when I send out certain emails. When the customer opens the email and clicks on the URL, it will uncheck the "allow emails" checkbox which will stop any further emails from being sent to the customer since my Rules checks to make sure that it is checked before it will fire the send mail action. Thank you for your response, I will look into that module.
    – Brandon
    Nov 28 '14 at 4:16
  • Check this patch that someone created in order to be able include a working Rules Link URL in an email: drupal.org/node/2356717 . You can also refer to JamesWilson's answer if you need help creating the actual Rule Action that changes the "allow emails" field. If this answers your question, please mark my answer as a correct one.
    – argiepiano
    Nov 28 '14 at 5:09
  • @argiepiano : I keep wondering what the pros/cons are about rules_link versus using the flag module. Do you think that would be a good question for me to post? What I mostly wonder: if I can achieve the same with Flag, I can probably reuse that module in much more occasions as compared to rules_link, unless there are other cases where the opposite is true. Please let me know ... Aug 27 '16 at 7:17
  • @Pierre.Vrains : While I've seen the Flag module in many answers (and from the description it looks like a powerful module), I have never used it - I have used Rules Link many times. It'd be great to have a question on this to see what people think. Thanks
    – argiepiano
    Aug 27 '16 at 17:09
0

You can definitely set the field value of a node with a Rules action assuming the referenced node is passed into the Rule.

Also, remember that in order to set a field value in a Rule, you have to first check to see that the field exists using a Rules condition (there is a specific condition for this).

Related question: How to change a field value with a Rules Action?

0

Perhaps try Rules Argument. https://www.drupal.org/project/rules_url_argument

Compose your URL using token field values and then check for these values in the path when the user clicks through (you may need the Path Rules module). IMO the path handling would be better done with a menu callback in a custom module, but if you want to use Rules, you should be able to use the above mods.

As a security measure, you may want to create a custom token so that a malicious 'user' can't unsubscribe another 'user' by guessing path vars.

2
  • Thank you for your response. I am trying to keep the site as "maintenance free" as possible. Just in case if I leave, someone else can pick it up without having to go over PHP. The learning curve for Drupal is high so I don't want to throw "oh and you have to know the Drupal 7 API as well".
    – Brandon
    Nov 28 '14 at 5:58
  • :) fair enough. I guess if the logic is all sitting in one place it's easier to maintain. Nov 28 '14 at 6:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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