0

I am trying to make a Rule where after the user logs in they are redirected to the front page except when they are setting their first time password or resetting their password To do it I want to use a Rule that acts on User Logged In, with a condition that checks if the url they are on has edit in the name, and if it doesn't then redirect them to the front page.

My issue is that when I try to use the Path Contains Text condition it never triggers, and if I try to print the url in a message as the action it is always empty.

What am I doing wrong? What do I need to do to get the results I want?

6
  • add a condition: NOT 'site:current-page:path', value: 'user/reset', then built your rule
    – pinueve
    Commented Feb 5, 2021 at 1:37
  • @pinueve which condition should I add to do that?
    – Eluchel
    Commented Feb 5, 2021 at 16:20
  • img is from D7, for D8 is the same, i.imgur.com/5LgDIOe.png
    – pinueve
    Commented Feb 5, 2021 at 17:14
  • Hmm, @pinueve that didn't work. It is still redirecting to the home page when people try to log in with their one time link
    – Eluchel
    Commented Feb 5, 2021 at 17:33
  • that works for D7, find out what URL takes to log in with their one time link, and replace redirect text in rule condition
    – pinueve
    Commented Feb 5, 2021 at 17:57

1 Answer 1

0

Here is a working example taken from the Rules Examples module, which is a submodule of D8 Rules Essentials.

langcode: en
status: false
dependencies:
  module:
    - tr_rulez
  enforced:
    module:
      - tr_rulez
id: redirect_to_home
label: 'Redirect to home on Login'
events:
  -
    event_name: rules_user_login
description: 'Issue #2975452-6: Redirect all users to "/" on login, except for when a one-time login password is used.'
tags:
  - login
  - redirect
  - rules_examples
config_version: '3'
expression:
  id: rules_rule
  uuid: 7263942c-3847-460d-af3f-6c78f80fbcc1
  conditions:
    id: rules_and
    uuid: a8c1bb95-b783-4238-a7e1-9b4b9fb96ca4
    conditions:
      -
        id: rules_condition
        uuid: f35e2d95-850d-455d-99e2-629e37b17cb7
        context_values:
          text: reset
        context_mapping: {  }
        context_processors:
          text:
            rules_tokens: {  }
        provides_mapping: {  }
        condition_id: rules_path_contains_text
        negate: true
  actions:
    id: rules_action_set
    uuid: d17285ef-4de4-498a-8b78-654cf79566ee
    actions:
      -
        id: rules_action
        uuid: a529b090-e6f3-4421-aede-75489267d888
        context_values:
          url: /
        context_mapping: {  }
        context_processors:
          url:
            rules_tokens: {  }
        provides_mapping: {  }
        action_id: rules_page_redirect

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.