Skip to main content
added 1773 characters in body; added 162 characters in body
Source Link
Pierre.Vriens
  • 36k
  • 40
  • 50
  • 182

Not sure if it will be your only probemproblem to be fixed, but you seem to be using the wrong token in your condition path. Try again using [site:current-page:path].either of these tokens:

  • [site:current-page:path].
  • [site:current-page:url].

ForBelow is an example of a rule (in Rules Export format) that uses this [site:current-page:path] token, and which you might wantillustrates how to use to create a variationeither of these tokens:

{ "rules_redirect_logged_in_user" : {
    "LABEL" : "Redirect logged in user",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "init" : [] },
    "IF" : [
      { "NOT user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "1" : "1" } }
        }
      },
      { "OR" : [
          { "data_is" : { "data" : [ "site:current-page:path" ], "value" : "node\/123" } },
          { "text_matches" : { "text" : [ "site:current-page:url" ], "match" : "something" } }
        ]
      }
    ],
    "DO" : [
      { "drupal_message" : { "message" : "Using the path [site:current-page:path] (or url [site:current-page:url]) makes no sense for authenticated users, which is why you are redirected ..." } },
      { "redirect" : { "url" : "somewhere_else" } }
    ]
  }
}

Some more details about the above Rule:

  • Rules Event: Drupal is initializing.
  • Rules Conditions:
    • the user should NOT be anonymous, AND
    • either (or both) of these conditions must be true:
      • the path is node/123 (assuming your homepage is a node with nid=8, adapt to fit your case, or omit this condition if the next condition is sufficient for your case).
      • the url contains the text something (adapt to fit your case, or omit this condition if the previous condition is sufficient for your case). Instead of using Comparison operation contains you could also use starts with, ends with or even a regular expression.
  • Rules Actions:
    • Show an appropriate message (adapt to fit your needs, or just omit it if you don't want such message at all, I like it for debugging purposes ...).
    • Perform a redirect to somewhere_else (adapt to fit your needs).

If you have the Rules UI enabled, you should be able to import the above rule in your own site. Then adapt it to fitfits your needs, refer to my answer and you should be good to "https://drupal.stackexchange.com/q/59598/39516"go.

Easy, no?

Not sure if it will be your only probem to be fixed, but you seem to be using the wrong token in your condition path. Try again using [site:current-page:path].

For an example of a rule (in Rules Export format) that uses this [site:current-page:path] token, and which you might want to use to create a variation of it to fit your needs, refer to my answer to "https://drupal.stackexchange.com/q/59598/39516".

Not sure if it will be your only problem to be fixed, but you seem to be using the wrong token in your condition path. Try again using either of these tokens:

  • [site:current-page:path].
  • [site:current-page:url].

Below is an example of a rule (in Rules Export format) which illustrates how to use either of these tokens:

{ "rules_redirect_logged_in_user" : {
    "LABEL" : "Redirect logged in user",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "init" : [] },
    "IF" : [
      { "NOT user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "1" : "1" } }
        }
      },
      { "OR" : [
          { "data_is" : { "data" : [ "site:current-page:path" ], "value" : "node\/123" } },
          { "text_matches" : { "text" : [ "site:current-page:url" ], "match" : "something" } }
        ]
      }
    ],
    "DO" : [
      { "drupal_message" : { "message" : "Using the path [site:current-page:path] (or url [site:current-page:url]) makes no sense for authenticated users, which is why you are redirected ..." } },
      { "redirect" : { "url" : "somewhere_else" } }
    ]
  }
}

Some more details about the above Rule:

  • Rules Event: Drupal is initializing.
  • Rules Conditions:
    • the user should NOT be anonymous, AND
    • either (or both) of these conditions must be true:
      • the path is node/123 (assuming your homepage is a node with nid=8, adapt to fit your case, or omit this condition if the next condition is sufficient for your case).
      • the url contains the text something (adapt to fit your case, or omit this condition if the previous condition is sufficient for your case). Instead of using Comparison operation contains you could also use starts with, ends with or even a regular expression.
  • Rules Actions:
    • Show an appropriate message (adapt to fit your needs, or just omit it if you don't want such message at all, I like it for debugging purposes ...).
    • Perform a redirect to somewhere_else (adapt to fit your needs).

If you have the Rules UI enabled, you should be able to import the above rule in your own site. Then adapt it to fits your needs and you should be good to go.

Easy, no?

Source Link
Pierre.Vriens
  • 36k
  • 40
  • 50
  • 182

Not sure if it will be your only probem to be fixed, but you seem to be using the wrong token in your condition path. Try again using [site:current-page:path].

For an example of a rule (in Rules Export format) that uses this [site:current-page:path] token, and which you might want to use to create a variation of it to fit your needs, refer to my answer to "https://drupal.stackexchange.com/q/59598/39516".