0

When users sign up, I create a new node and add that user into one of the entity reference fields through rules.

What I built so far is the following.

  1. After saving a new user event
  2. Create a new content item action (Parameters: type: advisor_student_matching_program, title: title comes here)
  3. Set a data value (Parameters: data: node_created.field_university_student, value: @user.current_user_context:current_user)
  4. Save entity (Parameters: entity: node_created, immediate: 1)

Everything works fine except for the third step.

uuid: 692696f4-4c6d-45cc-8a5b-3b69f1925bd0
langcode: en
status: true
dependencies: {  }
id: register_university_student
label: 'Register University Student'
events:
  -
    event_name: 'rules_entity_insert:user'
description: ''
tags: {  }
config_version: '3'
expression:
  id: rules_rule
  uuid: 6f4c1ccb-973c-48ec-aed1-637bdb50e301
  weight: 0
  conditions:
    id: rules_and
    uuid: 3f479a19-06b2-4e05-80c2-4cff28650409
    weight: 0
    conditions: {  }
  actions:
    id: rules_action_set
    uuid: abbb62e5-a610-4ab7-8e3a-f96a4570f049
    weight: 0
    actions:
      -
        id: rules_action
        uuid: 3bce44f5-accb-4239-9c1d-377f29debebf
        weight: 0
        context_values:
          type: advisor_student_matching_program
          title: 'title comes here'
        context_mapping: {  }
        context_processors:
          type:
            rules_tokens: {  }
          title:
            rules_tokens: {  }
        provides_mapping: {  }
        action_id: 'rules_entity_create:node'
      -
        id: rules_action
        uuid: eba88823-1ab3-493a-9b62-e22e49a2db4a
        weight: 0
        context_values: {  }
        context_mapping:
          data: node_created.field_university_student
          value: '@user.current_user_context:current_user'
        context_processors: {  }
        provides_mapping: {  }
        action_id: rules_data_set
      -
        id: rules_action
        uuid: 779eadc9-f208-4cfa-b37e-351126c56243
        weight: 0
        context_values:
          immediate: '1'
        context_mapping:
          entity: node_created
        context_processors:
          immediate:
            rules_tokens: {  }
        provides_mapping: {  }
        action_id: rules_entity_save
      -
        id: rules_action
        uuid: 18d0c0d6-d9c6-4fc9-8127-4291fe80081c
        weight: 0
        context_values:
          url: /register-uni-basic-information
        context_mapping: {  }
        context_processors:
          url:
            rules_tokens: {  }
        provides_mapping: {  }
        action_id: rules_page_redirect

1 Answer 1

1

Should have used user, instead of @user.current_user_context:current_user.

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.