Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi all,
I want to change the value of a profile2 field during a rules action with PHP. The name of the field is given by a variable called "fieldname", the field is an entity reference to an user:
$user_uid = $booking-user->uid;
$profile_name = 'profile_user';
$profile_entity = profile2_load_by_user($user_uid, $profile_name);
$field_change = $profile_entity->$fieldname;
$booking['und'][0]['target_id'] = 122;
profile2_save($profile_entity);
The profile is loaded but not saved... maybe profile2_save does not work within a rules action?
Best,
Tobias
Comments
Comment #1
VasilyKraev CreditAttribution: VasilyKraev commentedSame problem. After creating new user, I got system message, user with change e-mail, but no changes in profile.
I use following rule:
Comment #2
HenrikBak CreditAttribution: HenrikBak commentedI have got the same issue with profile2_save(). I'm using it within a custom rule and It simply doesn't save the profile.
Comment #3
VasilyKraev CreditAttribution: VasilyKraev commentedSeems as duplicate #1097684: Profile tokens are not available directly after adding/registering a user