1

I am using the Simplenews module for sending newsletters, and the Mandrill service for sending emails. When I send a test newsletter to the test user, the unsubscribe link should be redirected to particular node, for example to node/2.

How can I achieve this?

0

1 Answer 1

0

Use the Rules module and use the Rules (System) Event "Drupal is initializing" (= init). And add an extra condition related to the URL of your unsubscribe link. Add to that a Rules Action to perform a redirect to your node/2.

Here is a rule that should be close to what you'd need (assuming the path of your unsubscribe link is Some/Unsubscribe/Path):

{ "rules_redirect_unsubscribe_link" : {
    "LABEL" : "Redirect unsubscribe link",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "init" : [] },
    "IF" : [
      { "text_matches" : {
          "text" : [ "site:current-page:path" ],
          "match" : "Some\/Unsubscribe\/Path",
          "operation" : "regex"
        }
      }
    ],
    "DO" : [
      { "drupal_message" : {
          "message" : "Redirecting URL [site:current-page:url] ...",
          "type" : "warning"
        }
      },
      { "redirect" : { "url" : "node\/2" } }
    ]
  }
}

The above rule does not (yet) take into account to only apply the Rules Action for your "test user" (as in your question) only. But for anybody a bit familiar with the Rules module, that is a straight forward Rules Condition to add ...

And the above rule also uses a Regular Expression in its Rules Condition that could be simplified to a simplified version of it (not using such expression). However, if you have various unsubscribe links that all have a similar pattern, you only have to massage that expression in the above Rules Condition to have all such links fit in the same expression.

To experiment with this rule in your own site, just copy the entire Rules code above, and paste it in a new Rule in your own site, created via the "Import" function (available if the Rules UI submodule is enabled). Then further edit/refine to make it fit in your own environment (e.g the "Redirecting URL ..." message to be shown).

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.