I was wondering how to automatically update a user's realname when the corresponding Profile2 fields are updated:

Basically I have a site using Profile2. One profile type is called "Personal Data" and it is visible in the registration form. It has i.a. a first and a last name filed and must be entered upon registration. Everything works as expected so far.

However, if a user changes the last name, e.g. a woman called Dorothy Petrillo who marries and hence is called Dorothy Zbornak, the realname does not automatically get updated. I thought of using the Rules module for this update action but I am a bit stuck there:

So basically I know how to trigger the action of the profile type is updated. But how to I continue to force realname to update its value for that user?!

Thanks for the help!!!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

Status: Active » Fixed

Maybe you could add a Rule that when a Profile2 profile updated, to re-save the user account object. Otherwise we could provide some kind of reaction for 'Update a user's real name'.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

fraweg’s picture

Hello,

Maybe you could add a Rule that when a Profile2 profile updated, to re-save the user account object. Otherwise we could provide some kind of reaction for 'Update a user's real name'.

For me I can not do that. When I chose profile on rules I can not chose in the action "re save user account"

Thanks for any help
Frank

fraweg’s picture

Status: Closed (fixed) » Active
Dave Reid’s picture

Status: Active » Fixed

If you update to Realname 7.x-1.0, you should have an action 'Update real name' available.

fraweg’s picture

Status: Active » Fixed

Hello Thanks for your fast answer.

If you update to Realname 7.x-1.0, you should have an action 'Update real name' available.

I have test it with 7.x.1.0 and the dev version.For me both have no action called "Update real name".

What I did:

Create a rule with name "update realname" and give a value for "React on event " with "After updating an existing profile".
Then I save. Now I have no "Update real name" under "actions".

Do I something wrong?

Thanks for any help
Frank

fraweg’s picture

Status: Fixed » Active
fraweg’s picture

Status: Fixed » Active

Hello,

Please....can anyone tell how I can find the action "Update real name" or how I can create such a rule?
I really need this feature.

Best regards
Frank

drupalycious’s picture

In Realname 7.x-1.0, the action 'Update real name' is not available in rules.

Dave Reid, could you tell us how you made it available?

thanks

fraweg’s picture

Hmmm....

has anyone solve this issue?

Best regards
Frank

fraweg’s picture

@sp-drupy

Did you find this rule? For me there is no way to find it.

Best regards
Frank

Dave Reid’s picture

If Rules module lacks a way to connect a profile2 object to its root user account object, then that would be a bug in profile2.

drupalycious’s picture

@ Fraweg:
no I couldn't find it...

@ Dave Reid:
I thought you proposed this solution because you tested it already and indeed could find this action under rule.

Might be an issue with profile 2 as you said.

Dave Reid’s picture

I do not use Rules, so it was an assumption and something I would expect works out of the box.

Dave Reid’s picture

Project: Real Name » Profile 2
Version: 7.x-1.0-rc2 » 7.x-1.x-dev
Component: Documentation » Miscellaneous

Transferring this issue to the Profile2 module. Could a maintainer there please reply on how you can create a rule that responds to after a profile2 entity is updated, to invoke an action on the user account object that the profile2 belongs to?

Dave Reid’s picture

Ok I installed profile2 and rules to test this out and it seems that Rules doesn't want to pick up anything that already exists in hook_action_info() and we now have to add yet another hook, realname_rules_action_info(). Will fix in Realname 7.x-1.x now. When this lands you should be able to create a rule like the following:

{ "rules_rule_update_realname" : {
    "LABEL" : "Update Real name",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "realname", "profile2" ],
    "ON" : [ "profile2_update" ],
    "DO" : [ { "user_realname_update" : { "account" : [ "profile2:user" ] } } ]
  }
}
Dave Reid’s picture

Title: Update realname if profile fields are changed » Add rules integration for RealName
Project: Profile 2 » Real Name
Category: support » feature
Dave Reid’s picture

Status: Active » Needs review
FileSize
809 bytes

Patch against RealName 7.x-1.x for review.

Dave Reid’s picture

Status: Needs review » Fixed

On more review, it seems that this is only a problem if you're using the 'Profile2 Pages' module. Otherwise updating a profile does actually clear the username automatically.

Committed #18 to 7.x-1.x: http://drupalcode.org/project/realname.git/commit/6fc61d5

drupalycious’s picture

Hi!

indeed I am using "profile2 pages". Does your patch fixes the problem in this case? or is it better not to use profile2 pages?

Thanks for looking at this issue.

fraweg’s picture

Hello Dave,

thanks so much for your work! With the dev-version and the rule the name will be updated!

But there is one another issue. I will explain it:

When I update the name, save the profile and close it I will redirect to the userpage. But the page is is not available. Only the "old" page is available. For example:

- The name is "frank" at first time when I activate the realname-module and has the path "http://example.net/users/frank"
- I change the name to "frank1" I will redirect to "http://example.net/users/frank1" but only the path "http://example.net/users/frank" exist.
- I change the name to "frank2" I will redirect to "http://example.net/users/frank2" but only the path "http://example.net/users/frank1" exist.
- I change the name to "frank3" I will redirect to "http://example.net/users/frank3" but only the path "http://example.net/users/frank2" exist.

and so on.

Have you an idea how to fix that?

Best regards
Frank

drupalycious’s picture

The following could be useful and is related to the subject:

If you use Views Bulk Operations module together with the Views module, you will see that there is an option there called " Update real name (realname_action_realname_update)".

fraweg’s picture

Hello sp-drupy,

can you explain a little bit more in witch case you use "Views Bulk Operations" in combination with user profiles and realname? I'am new in that.

Thanks a lot
Frank

fraweg’s picture

Ok. I will start a new issue. I think the feature request is solved...

Here is the new link:

http://drupal.org/node/1659012

Best regards
Frank

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

ipwa’s picture

After uninstalling this module everytime I save a view, the site goes down and I found this on my dblog

1 orphaned actions (realname_action_realname_update) exist in the actions table.