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.
In 5.1.0, I see the username overridden by RealName, but it prevents comments from being submitted with the error message "You have to specify a valid author." The module seems to be using the RealName when submitting comments. this should swing back to the username.
any workarounds?
Comment | File | Size | Author |
---|---|---|---|
#11 | realname-comment-6.x-1.x-dev.patch | 564 bytes | jcwatson11 |
Comments
Comment #1
tborrome CreditAttribution: tborrome commentedsolved 2 problems (comments and user edits) by modifying realname_form_alter with the following:
1. change:
case 'user_profile_form'
to:
case 'user_edit':
2. Add:
case 'comment_form':
if (!isset($user->realname)) {
$user = user_load(array('uid' => $user->uid));
}
$form['author']['#value'] = $user->realname_save;
break;
Here's the modified: realname_form_alter
function realname_form_alter($form_id, &$form) {
if (!user_access('use realname')) {
return;
}
global $user;
switch ($form_id) {
case 'user_edit':
$form['account']['name']['#default_value'] = $form['_account']['#value']->realname_save;
break;
case 'contact_mail_user':
if (!isset($user->realname)) {
$user = user_load(array('uid' => $user->uid));
}
$form['from']['#value'] = check_plain($user->realname) .' <'. check_plain($user->mail) .'>';
break;
case 'contact_mail_page':
if (!isset($user->realname)) {
$user = user_load(array('uid' => $user->uid));
}
$form['name']['#default_value'] = $user->uid ? $user->realname : '';
break;
case 'comment_form':
if (!isset($user->realname)) {
$user = user_load(array('uid' => $user->uid));
}
$form['author']['#value'] = $user->realname_save;
break;
}
}
sorry don't know how to create a patch yet.
Comment #2
NancyDruWith the other changes I have committed, I am not seeing this. Please try the -dev version when it rolls up this evening. If the problem is gone, please mark this issue as "Fixed."
Comment #3
NancyDruComment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #5
jcwatson11 CreditAttribution: jcwatson11 commentedThis is happening in 6.x-1.1-rc1.
Comment #6
NancyDruPlease try the -dev version. You may need the patches I created for Token.
#325227: Provide e-mail and commenter homepage tokens for comments
#307520: Date formatting function
Comment #7
jcwatson11 CreditAttribution: jcwatson11 commentedOkay. I'll try.
Curious. I briefly reviewed the two patches you mentioned. Why would those two patches be related to not being able to comment?
Comment #8
jcwatson11 CreditAttribution: jcwatson11 commentedI was wrong. I emptied cache with 6.x-1.1-rc1 and it works fine. Sorry about that. Thanks for your help.
Comment #9
jcwatson11 CreditAttribution: jcwatson11 commentedClosing issue.
Comment #10
jcwatson11 CreditAttribution: jcwatson11 commentedI was wrong again. The fix actually doesn't work. The only reason why it was working for me was that I was logged into the site as the admin account. Regular users still can't make comments, and are getting the exact error message posted at the top of this thread. "You have to specify a valid author." I tried both dev and rc1 versions and it's happening in both as a regular user.
Comment #11
jcwatson11 CreditAttribution: jcwatson11 commentedFor 6.x, a slightly modified version of the fix posted at the top of this thread is in order. I have created a patch based on the 6.x-1.x-dev code downloaded today. So I know it's current. I would imagine that if you didn't incorporate the fix from the first reply in this thread in the 5.x release, it would need it there too, but I would not be able to test that for you. Here's the 6.x patch that fixes the issue.
Comment #12
NancyDruCommitted to both branches.
Comment #13
jcwatson11 CreditAttribution: jcwatson11 commentedThanks!
Comment #14
NancyDruActually, I have found a problem with anonymous users.
First $form['author'] is only set for an existing comment, and it seems to be fine on all my sites even without any of these patches.
$form['name'] is used for a new comment. This is where I am seeing a problem. It is pre-filling the name and email address with values that I don't seem to be able to successfully alter. I don't have any idea where it is getting these values either - they are from an earlier comment, but even after I change the comments in the database those values are still there.
I am totally baffled at this point and going to leave it for a little while in hopes that something will spring to mind.
Comment #15
jcwatson11 CreditAttribution: jcwatson11 commentedI'm sure it's a good catch. I look forward to your elaboration.
Comment #16
NancyDruAnother pair of eyes would be nice...
Comment #17
lomz CreditAttribution: lomz commentedSubscribing
Comment #18
NancyDruI am no longer seeing this issue.
Comment #19
ethosophical CreditAttribution: ethosophical commentedI'm still seeing this issue after applying the patch and upgrading to the latest dev version.
Comment #20
Magnity CreditAttribution: Magnity commentedThis is still occuring in 6.x-1.1-rc3.
Comment #21
lomz CreditAttribution: lomz commentedTried -dev?
Comment #22
ethosophical CreditAttribution: ethosophical commentedI've tried dev.
Comment #23
mehlbye CreditAttribution: mehlbye commentedSubscribing...
Any news to solve this?
Comment #24
lomz CreditAttribution: lomz commentedAs far as I know it is solved.
Comment #25
ethosophical CreditAttribution: ethosophical commentedDitto.
Comment #26
coderintherye CreditAttribution: coderintherye commentedJust to note, this issue is not solved in 5.x dev, I can't test 6.x right now, so don't know, but wanted to mention that here. Although, I am close to a solution.
Comment #27
mehlbye CreditAttribution: mehlbye commentedI'm running RealName 6.x-1.1-rc3 on 6.8, and I can't submit comments (specify valid author - error)
Comment #28
NancyDruOthers indicate that it is fixed in 6.x-1.x-dev, please try that version.
Comment #29
mehlbye CreditAttribution: mehlbye commentedSame in 6.x-1.x-dev: Please specify valid author. Only way I can get to comment is if username is identical to full name...
Comment #30
BerdirWe are having a similiar problem with privatemsg, see #349022: Private Message to work with RealName module. I am wondering why it is necessary to change $account->name. Isn't it possible, atleast with drupal 6, to override the username-theme *without* changing $account->name? What about a preprocess-hook that does set the $account->name attribute, then it is only changed in theme functions.
Something like (untested):
I don't really like to add a realname-specifiy check to privatemsg, would be great if this can be solved in another way.
Comment #31
Liliplanet CreditAttribution: Liliplanet commentedsubscribe ... thx!
Comment #32
NancyDruWith the new "forms bypass" feature this should be fixed. It is only available in the -dev version.
Comment #33
Liliplanet CreditAttribution: Liliplanet commentedThank you NancyDru! this is tremendous.
Please what would I add to bypass the Private Message form?
Wishing you a Wonderful 2009!
Lilian
Comment #34
NancyDruI don't use that module, so I don't know. Perhaps the issue mentioned in #30 will turn up something.
Comment #35
BerdirNo, it does not yet work with privatemsg.
The privatemsg form does not save the name of the current user but the recipients, and it is possible to define multiple recipients, for example "name1, name2, name3". So there is probably no easy way of replacing the names. The exact problem happens when a user clicks on a profile link to send a user a message, a url like "messages/new/{id}", the form function then uses the attribute name to display the username. When submitting, the username is validated and because it can't be converted back to a user object, it is considered invalid and the validation fails.
However, I still don't understand why $user->name needs to be overwritten. When I simply comment out the following line:
in the function realname_user, everything seems to work just fine, the theme function phptemplate_username in realname_theme.inc is called and the realname is displayed correctly. If other modules access $user->name instead of theme('username', $user), they probably want/need the actual username and not anything else.
Comment #36
NancyDru@Lilian: Can you go ahead and try commenting that line out, please?
@Berdir: Other than that some people don't use the "Override username theme," it does seem to be working for me. I have not yet seen a place where the realname is not being displayed. I do know of places (including the user module itself) that fail to use theme_username (for example, check #73813: Main Navigation Box should allow for greater flexibility in customization (user.module)) and don't really need the unmodified version.
So, I'm asking that all users of this module try commenting the line suggested (in function realname_user) and document any failures to show the realname. If you do this, you will need to make sure that "Override username theme" is turned on.
If it turns out that this solves a lot of problems, perhaps we can simplify the module and make "Override username theme" the default rather than an option.
Comment #37
NancyDruI just committed a change the "Override username theme" default to true and removed changing $user->name.
Comment #38
NancyDruComment #39
BerdirThe new dev version does work fine for me.
Comment #40
NancyDruThanks for the update.
Comment #41
digemall CreditAttribution: digemall commentedThe new dev-version works fine for me too, and so for example send msg function in PrivateMsg works correctly.
But now another module (tribune) shows user login name instead of realname in msg entries.
Before installing the dev-version, this module show realname correctly.
Does anyone have an idea to fix this ?
I have D6.8.
Comment #43
NancyDru@digemall: I just transferred an issue to Tribune - please check that issue queue.
Comment #44
digemall CreditAttribution: digemall commentedOk thank u NancyDru ;)
Comment #45
NancyDruComment #46
Magnity CreditAttribution: Magnity commentedIs this issue fixed just for -dev at the moment or has it been committed to the stable branch?
Thanks,
Comment #47
NancyDruWell, according to the project page, this is still in the -dev version.
Comment #48
pianomansam CreditAttribution: pianomansam commentedThis issue is still unresolved in the non-dev version of 5.x-1.1
Part of the code is there, but it is commented out and missing a line. Under realname_form_alter, there should be a switch for the case "comment_form" that looks like this:
Comment #49
NancyDruPlease check the -dev version. Once a release is published it cannot be changed; that's why -dev exists.
Comment #50
pianomansam CreditAttribution: pianomansam commentedNancDru, I am using this in a production site. I do not wish to be using -dev versions for a live production site. If this has made to the -dev and the -dev is stable, why don't we release the -dev as the production version?
Comment #51
hass CreditAttribution: hass commentedBranch is no longer supported.