0

I have a content type Proposal with a entity reference field Proposed by. This is an autocomplete field that targets Users in the application. You can give in multiple users that are in the application.

But now I would like to give the possibility to the user that they can give in user that are NOT in the application. So they can enter email addresses from random persons, they will receive an email with a link to register. But how can I get this data? Because it's not saved when the user isn't in the application.

I tried to do this with hook_node_validate but this is the result I get:

array (size=1)
'und' => 
  array (size=4)
    0 => 
      array (size=2)
        'target_id' => string '26' (length=2)
        '_weight' => string '0' (length=1)
    1 => 
      array (size=2)
        'target_id' => null
        '_weight' => string '1' (length=1)
    2 => 
      array (size=2)
        'target_id' => string '' (length=0)
        '_weight' => string '2' (length=1)
    'add_more' => string 'Add another item' (length=16)

So no email address that I gave in.. Just a target_id = null. How could I do this?

1

Entity Reference can reference entities only. It would be a really big hack to the module to allow non-entities to be referenced. But there is no need to.

There are dedicated modules for exactly what you are trying to do. Instead of Entity Reference, create User Relationships. Use User Relationship Invites submodule, it

allows users to specify a relationship to a user that they invite to join the site.

Invitation is done by using e-mail, so it seems this will fully satisfy your use case.

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.