1

I have user profile with fields:

  1. date field: "date of birth" (format: y-m-d)
  2. node reference field "card_ref" which should automatically reference to content-type "cards" node. (users cannot change it only view it)

and content-type "cards":

  1. title field
  2. date field (multiple values, format: m-d)

so i'd like to make auto-reference to existing node "cards" which have same date-field value but different format.

For example:

I have "cards" nodes: (title - dates)

  1. Card A - 01.23, 03.11, 05.02
  2. Card B - 02.14, 07.01
  3. Card C - 11.11
  4. Card D - 02.10, 03.02, 05.07, 09.14

After new user registers his account with date of birth: 1977.07.01, I need "card_ref" field to automatically assign him "Card B" or if entered date of birth: 1234.03.02, "card_ref" should be assigned to "Card D" and so on...

should i use custom module or it is possible to use some existing modules? maybe with views reference field, or rules?

any suggestions please? (for drupal 7)

Thank You..

1

I found the answer by creating own module.

First I create the View which finds Card nodes by dob field of the user, then inside the hook_user_presave() function I call views_get_view_result() and finally assign the card_ref field like this:

$edit['field_card_ref']['und'][0]['target_id'] = $card;

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.