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!!!
Comment | File | Size | Author |
---|---|---|---|
#22 | realname_update_vbo_views.png | 60 KB | drupalycious |
#18 | 1414140-realname-rules.patch | 809 bytes | Dave Reid |
Comments
Comment #1
Dave ReidMaybe 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'.
Comment #3
fraweg CreditAttribution: fraweg commentedHello,
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
Comment #4
fraweg CreditAttribution: fraweg commentedComment #5
Dave ReidIf you update to Realname 7.x-1.0, you should have an action 'Update real name' available.
Comment #6
fraweg CreditAttribution: fraweg commentedHello Thanks for your fast answer.
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
Comment #7
fraweg CreditAttribution: fraweg commentedComment #8
fraweg CreditAttribution: fraweg commentedHello,
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
Comment #9
drupalycious CreditAttribution: drupalycious commentedIn 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
Comment #10
fraweg CreditAttribution: fraweg commentedHmmm....
has anyone solve this issue?
Best regards
Frank
Comment #11
fraweg CreditAttribution: fraweg commented@sp-drupy
Did you find this rule? For me there is no way to find it.
Best regards
Frank
Comment #12
Dave ReidIf Rules module lacks a way to connect a profile2 object to its root user account object, then that would be a bug in profile2.
Comment #13
drupalycious CreditAttribution: drupalycious commented@ 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.
Comment #14
Dave ReidI do not use Rules, so it was an assumption and something I would expect works out of the box.
Comment #15
Dave ReidTransferring 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?
Comment #16
Dave ReidOk 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:
Comment #17
Dave ReidComment #18
Dave ReidPatch against RealName 7.x-1.x for review.
Comment #19
Dave ReidOn 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
Comment #20
drupalycious CreditAttribution: drupalycious commentedHi!
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.
Comment #21
fraweg CreditAttribution: fraweg commentedHello 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
Comment #22
drupalycious CreditAttribution: drupalycious commentedThe 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)".
Comment #23
fraweg CreditAttribution: fraweg commentedHello 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
Comment #24
fraweg CreditAttribution: fraweg commentedOk. 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
Comment #26
ipwa CreditAttribution: ipwa commentedAfter 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.