Closed (works as designed)
Project:
Real Name
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
4 Aug 2011 at 15:29 UTC
Updated:
23 Apr 2021 at 09:46 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Tsubo commentedI have a similar issue. I'm also using the Token module - and in some places [user:name-raw] created by the Realname module 'is' available - and in some instances not.
Comment #2
drumnjo commentedsubscribing
Comment #3
manas_rocks commentedYou may refer drupal guide for api
Comment #4
jvieille commentedThis seems a bug, appearing in the D6 branch too
There is an option in the Realname General config tab " Overwrite user fields in view to show realnames", but it has no effect.
There is no way to get the original login name in a views field.
Comment #5
dddbbb commentedAny word from the maintainers?
Comment #6
dddbbb commentedBump.
Comment #7
Ashraf Amayreh commentedMajor bump. This is really problematic as there's no way to get the username in views now and all views depending on the username become broken. There's a field for realname, so why hijack the username field?
Comment #8
Ashraf Amayreh commentedA not so clean workaround:
1. Use Views PHP module.
2. In the view you want, add user UID field and exclude it from display then add global:PHP somewhere following it.
3. In the global:PHP field, you will have access to previous field values, in this case, you want the user ID.
4. In rewrite output for the global:PHP field, you can get the actual username with this code snippet.
Comment #9
dddbbb commented@ominds Cheers for posting a workaround - however hacky. We do really need this to be resolved in Real Name as the current hijacking does seem a little pointless and certainly causes problems.
Does this qualify as a 'major' issue? Breaking Views basic principles is pretty bad. Views as you know is a major contrib module used on most Drupal sites & username is a pretty basic building block within Views. Thoughts?
Comment #10
dddbbb commented@ominds I can't seem to get your workaround to work (nothing is output by the global:PHP field).
Comment #11
heorhi lazarevich commentedFor Drupal 6 branch I solved the problem by clearing the views cache (admin/build/views/tools) and rebuilding RealNames for all users (admin/user/realname/recalc)
Comment #13
tommyk commentedin response to #11 re: Drupal 6
Following those steps (I also have Disable views data caching checked), the result for me on Drupal 6 with realname-6.x-1.x-dev is that in my view, my Realname: Name field now displays the Username and so does the User: Name field.
That is, until I click into a user profile. After I do that once, and go back to the view, that user has the RealName rebuilt and it shows in both fields on the view.
So it seems that both fields will display the same always.
Comment #14
dddbbb commented@ominds I now have this working as per your suggestion. Must've been late...
Comment #15
brightboldAgreed that this issue deserves some attention, especially while the RealName autocomplete issue is unresolved. (See #1194086: Real Name not working for user references). For instance, I'm using Organic Groups in Drupal 7. To add a user to a group, OG uses an autocomplete field. But the lookup only works with username, not with realname. So I tried to make a View that will show both the RealName and the username, so that group managers can search on RealName and get the username to input into the OG field. Being able to choose which way the username field displays in this context would be really helpful!
Comment #16
brightboldI also had trouble implementing the workaround code in #8 (I'm sure it's not you, @ominds, it's me!) but got it to work with the following modifications:
Value code:
Output code:
<?php print $value; ?>Thanks for the hack, @ominds!
Comment #17
dddbbb commentedJust to be clear, we really need this fixed in the module properly though. The workaround in #8 is very handy for now but we really shouldn't have to be resorting to it.
Comment #18
bbjay commentedIs anyone working on this module? It's a great module, but I am thinking about temporarily uninstalling until this issue is fixed. I don't know if uninstalling would break anything though. Has anyone uninstalled it safely without any issues?
Comment #19
dddbbb commented@bbjay - I've managed to uninstall without any issues.
Comment #20
WebJohn commentedRealname gives us the 'Realname' field in views to output that for a user. So the module should somehow be told to not touch the views field for 'User: Name' or at least respect the field setting (under 'more') for:
"Use formatted username - If checked, the username will be formatted by the system. If unchecked, it will be displayed raw."
Or does this mean that it's actually a Views issue?
Comment #21
Po3t commentedSo no word on this I take it? Is nobody maintaining this anymore? This is a serious bug.
Comment #22
Po3t commentedBumping this back up as it's still a serious issue.
Comment #23
burgs commentedI seem to be able to get the username without a user_load, by creating a custom template file for the username field, and replacing
print $output;with
print $row->users_name;It's not a fix, but it's a bit less of a performance hit, if it works for everyone.
Comment #24
zengenuity commentedHere is a patch that adds a "User: Name (raw)" field to Views that shows an unaltered version of the username. There already appear to be sort, filter and argument handlers for the raw name, so this only adds a field.
Comment #25
Maks commentedThank you very much, Zengenuity! Patch works great!
Comment #26
IWasBornToWin commentedPatch works GREAT! I'm changing this to critical in hopes of getting the maintainer's attention so we can continue to beg for your help. Can you please commit this patch to the latest version? Sorry for begging but this post is almost a year old and we really need your help. Thanks and thanks again for the patch in #24
Comment #27
dave reidIt may be a year old, but it's only been less than a week since this issue has had a valid patch that I can review. So no, please don't abuse the priority field just to get attention unless it's actually been a year since the patch has been uploaded.
Comment #28
IWasBornToWin commentedAbuse? I'd say every person on here has experienced abuse. Glad we got your attention. I hope you will commit, thanks.
Comment #29
dddbbb commented@IWasBornToWin - you don't speak for everyone on this thread and Dave's right - you're abusing the system. Read up on the issue Priority values: http://drupal.org/node/45111
This particular bug has frustrated me immensely - in fact, I posted the issue in the first place. But we've got to have a good process or nothing would ever get done properly.
If you want to help expedite this patch being rolled into dev then I suggest you conduct further testing and update this issue with the results. You could also help by encouraging others to do the same.
Comment #30
IWasBornToWin commentedI've tested it and it works great....thanks
How do I speak for those of us, including your own admitted frustration, who wait, and wait, and wait? After almost a year the only thing which motivated the maintainer to show up was (or it appears) by me changing the status to "critical". I realize this can be subjective to who thinks something is critical. If you do not personally feel abused with the process of this post then I apologize for speaking for you.
I realize Dave Reid is busy and he's a great asset to Drupal and I also expect he has a great reason for not being able to tend to this, but I think there is a great argument for users who beg and never get help...until a status is changed. I'm not sure what the solution is, but there certainly seems to be a gap.
I'll help any other way I can but I applied the patch and it works great. Let me know if I can do anything else...thanks.
Comment #31
neclimdulNo, he was forced to respond because your comment was disruptive to the queue not productive. The time he(and now I) took to address that disruption is time he didn't get to spend addressing other issues and only delays actually getting this committed.
The fact is, as an open source developer you commonly have to rely on the community to resolve feature requests for you. Those with more interest will get patches and then you can review them. His absence in the issue to this point is not a big deal and a week is not a long time to wait for a review. Since Dave has a long track record of maintaining modules, attacking him on this fact only make you look bad unfortunately.
So some patience and considerate queue participation will go a long way to making the software better and making our great community... great. Until he can review and commit it, feel free to enjoy the patch that seems to be working for you.
Comment #32
drakythe commentedI did a quick test, and the patch does seem to work, however it is not RTBC. Someone with more time on their hands needs to re-roll after eliminating the whitespace errors, please. I am switching status to Needs Work since the patch has now been tested 3 times, and seems to work in all 3 cases, but the patch still contains whitespace errors.
Comment #33
dddbbb commentedI'm pretty new to supplying patches on d.o so bear with me. I'm hoping that this solves the whitespace issues mentioned in #32. I haven't got time to test it yet though so if anyone can try this out that would be great.
Comment #34
IWasBornToWin commentedI just applied and used patch - works great.
Comment #35
drakythe commented3 up 3 down, Patch in #33 looks good.
Comment #36
dddbbb commentedThat's great news.
a) because this issue's been open for quite a while now
and
b) because that was my first patch for a contrib module EVER and now I'm feeling some sort of warm open source community glow in my belly :D
Comment #38
dddbbb commentedWill this be committed to dev then?
Comment #39
IWasBornToWin commentedAny idea when this will be committed to Dev?
Comment #40
WorldFallz commentedThe patch works, but I'm not sure it's the right answer. Do we really want 3 username fields?
Seems to me it should just be:
I'll see about rolling an updated patch.
Comment #41
WorldFallz commentedTurns out there's a lot of views user name field handlers that would probably have to be extended to fix this, so it was easier to leave the original 'User: Name' along with the current behavior and add a 'User: Username' field which is basically the field from #33 but without a separate "Realname" section.
Patch attached.
Comment #43
WorldFallz commentednow with more unix
Comment #44
WorldFallz commentedComment #45
IWasBornToWin commentedI'm pretty sure we already had the first two you mentioned in #40. The Raw one was the only one missing.
Comment #46
WorldFallz commentednope, with the patch as-is against the current dev there were the three options i bulleted in #40. i don't think a single realname field warrants it's own field category and the 'User: Name (raw)' option as named in the previous patch creates a 'User: Name (raw) (name(raw))' field line item when added to views which is an ugly/confusing name.
Comment #47
hass commentedIt's minor, but the indentation of the last closing bracket is 3 spaces and should be 2 spaces only. :-)
Comment #48
smartsystems160 commentedCan this be patch be port into drupal 6?
Comment #49
Po3t commentedAny chance we can get an updated version rolled out sometime soon? There's been no change to the Drupal 7 version since May 2012. Thanks!
Comment #50
achtonThis is a patch for the 6.x-1.x version that is based on WorldFallz' patch in #1239478-43: How to display a user's username (not real name) in Views once RealName is enabled?. The syntax in
realname.views.incis quite different in 6.x and I'm not a Views developer, so I'm not sure the approach is entirely sound, but it Works For Me(tm).Comment #52
dddbbb commentedThe patch in #43 worked for me.
Can we get the 7.x version committed?
Comment #53
drupalycious commentedHello,
just to mention that the patch in #43 worked for me too.
It is very useful if you need to export user accounts through a view.
thanks
Comment #54
smartsystems160 commented#50: realname-d6-views-username-field-1239478-50.patch queued for re-testing.
Comment #56
smartsystems160 commented@achton thanks for the patch in #50. will test it asap and report my findings.
Comment #57
tim.plunkettRestting status.
Comment #58
devenpro commentedGot a workround (only for drupal 7) solving problem with field UI and Rules.
Step 1: Create a text field in user account. Name it somethig like "User Username".
Step 2: Create a rule to trigger "Before saving a user account". Name it somethig like "Check for username and create duplicate".
Step 3: Set condition "User has role(s)". And select authenticated user or desired roles.
Step 4: Add an action to "Set Data Value". In the "Specifies the data to be modified using a data selector" select [account:field-user-username] and replace it with [account:name].
Its done at its primary level and whenever user account is going to be saved this rule will run and will keep updated the username value.
You can make your way smooth by:-
1. Creating a view with VBO to update existing users.
2. And then apply a condition to check if data value for username has been modified.
3. Hide "User Username" field from user edit form so it could not me edited with "css" or "display suit" or "field permission" or _ _ _ _.
Comment #59
dddbbb commentedThere is a patch in #43 that passed testing and seems to working for people in D7. Requests to get this committed to the D7 dev version appear to have been obscured by new efforts to get this back ported to D6.
Fair enough but can we not just get the D7 patch committed to dev and deal with the D6 version separately? This thread is pretty old now, it would be nice to at least put *some* of it to rest. This was a D7 issue in the first place after all.
Comment #60
fuzzy76 commentedThis causes RealName to actually break sites when installed. How this isn't atleast major in priority is beyond me. We have several administrative user views that use username for creating URLs . And they all broke when installing RealName.
Oh, and btw, this issue seems to be a duplicate of #1130350: Make both themed and unthemed username available to views? from April 18, 2011.
Comment #61
dddbbb commented#1130350: Make both themed and unthemed username available to views? is a D6 issue, does that still make it a duplicate? Either way, I guess this further reinforces my point in #59: *this* is a D7 issue and we have a working, reviewed & tested D7 patch.
Can someone please commit the patch in #43?
Comment #62
fuzzy76 commentedHow to look at it is actually up to the maintainer of the individual project. But the common procedure for bugs like this is to first fix them in the newest stable core version (D7) and then backport to older maintained version (D6) in the same issue. So to answer your question, most project leaders on d.o seem to use a single issue for several major core-versions as long as the bug is the same.
Comment #63
dddbbb commentedYes, I've seen different approaches in different issues with different maintainers. I'm never sure what the preferred/common approach is so thanks for letting me know.
Seeing as it seems to boil down to maintainer preference, could Nancy Dru and/or Dave Reid perhaps let us know what their approach is for this issue/module?
Comment #64
dave reidI would probably prefer an approach that creates a replacement handler for the existing User: Name field or something that renames it to 'Login name' and adds an optional option to output the real name, and have a separate 'User: Real name' field handler. I wonder if we could get input from the Views maintainers on how to handle login name vs real name considering that the existing Views handler tries to do both?
It's also unclear if the RTBC here is for the latest patch or the one before it. There doesn't seem to be a whole lot of agreement here.
Comment #65
dddbbb commentedAs far as I can tell, the RBTC is for the D7 patch in #43.
Comment #66
marleo commentedSubscribing. D6.
Comment #67
fuzzy76 commentedMarleo, please do not subscribe by posting, but use the follow-button on top.
Comment #68
chrisjlee commented@marleo follow button: http://drupal.org/node/1306444
Comment #69
Christopher Riley commentedIts been a while since this was last updated. I would like to see patch #43 applied as well as it also having the additional option of being able to link back to the users profile.
Comment #70
mvc#43 works perfectly for me as well on d7. i wasn't able to display usernames (necessary for my client to use the masquerade module) until this patch was applied.
Comment #71
jeromev commented#43 works so beautifully it makes me cry. Thanks WorldFallz. I would categorize this as a feature request.
Comment #72
dddbbb commentedUn-breaking access to the username string is a feature request? No.
I'd categorise this as a bug that has a working fix for D7 that needs to be committed before it makes anyone else cry :D
Comment #73
jeremycaldwell commentedI was able to replace the "username" with the "realname" for my View's title without any modification to the module or applying any patches. I'm curious as to if this works for other people too so I have outlined how I was able to accomplish it.
That should be all you need to create a page or block with a title like "Articles by Jeremy Caldwell".
Screenshots of the Views argument:
http://dl.dropboxusercontent.com/u/3170856/Screenshots/2013/09-September...
http://dl.dropboxusercontent.com/u/3170856/Screenshots/2013/09-September...
Comment #74
brightbold@eternalistic - Right, but what we're talking about here is the opposite. What if instead of "Jeremy Caldwell" I need to see "jcaldwell37" for some reason. Currently I can't choose to do that in Views — you get the realname whether you choose realname or username as the field you want outputted.
Comment #75
dddbbb commentedIt's not just about views either, AFAIK this bug affects tokens and the like too. Let's chalk #73 up as another possible workaround that some users visiting this thread may find useful depending on their use case.
Comment #76
hass commented43: realname-views-username-field-1239478-43.patch queued for re-testing.
Comment #77
hass commentedHide all patches except #43
Comment #78
hass commentedI'd like to commit this to D7, but I do not understand why the patch removes so many lines. Can someone write up a summary and give me a short intro so I can review finally? A repro case would be great.
Comment #79
aclubb commentedHave a few reservations re #43:
1) It gets rid of handlers for the realname field which are present in the existing module, hence why patch removing so many lines. For example, if you have a contextual filter for a view using the realname field, will break as the handler is removed by the patch. However, these can be by and large dealt with using existing views handlers, so no need to remove.
2) In terms of whether it makes sense to have 3 fields for username (e.g. 'user: name', 'realname: real name', 'user: name (raw))', I take the point per #40/41 that bit redundant/confusing to maintain all of these. However, as implemented in #43, looks like will potentially cause some existing views to break, as the realname field is effectively lost. So I think best to create an additional raw username field to better support backwards compatibility, but agree better to use 'user: username' instead of 'user: name (raw)' for the raw username, so you don't end up with double (raw) in replacement tokens.
3) In addition, would likely make sense to provide regular set of sort, argument, filter handlers for this new raw username field as well. Additionally, supporting realname substitution in titles/breadcrumbs for both uids and raw usernames is something that will likely be useful, so have included.
Attached patch addresses above, but as my first Drupal patch, I expect it to fail horribly... There are also existing issues with validation of names in contextual filters when RealNames installed which haven't addressed, as will need new plugin to deal with.
PS I'd think that if https://drupal.org/node/1609088 were fixed (which shows no signs of happening, as proposed resolution has potentially significant impacts), could potentially avoid having to touch this in Real Name at all, as you could just use uncheck "Use formatted username" for the name field to access the raw username, which can't at moment as will cause an "Undefined index: uid in views_handler_field->get_value()" error.
Comment #80
dr.osd commented#79 this patch fix my problem. Token user:name-raw get real name instead of original username.
Comment #81
rosell.dk commentedThe hack in #8 is for Drupal 6. In Drupal 7, it should go like this:
Otherwise you get an error like this:
Comment #82
rosell.dk commentedThe reason is of course that the api has changed
https://api.drupal.org/api/drupal/modules%21user%21user.module/function/...
Comment #83
timmarwick commentedFor those looking for an immediate solution, but not wanting to patch realname module itself, the workaround in #43 can also be implemented easily via you own custom module:
Clear cache, and you will now have a new field available in views (provided you have some sort of relationship to the user entity), called 'User: Username (Username)', which will display the original, raw user->name.
You could also simply implement hook_views_data() directly, but I personally have gone with hook_views_data_alter().
Comment #84
jeromev commented@pocketfluff #83 +1 thanks
Comment #85
kennyacock commentedThe patch in #43 seems to have done the trick for me.
I gratefully thank you!
Comment #86
christianadamski commented#83 works fine, though I do think, it should not be necessary.
However, there is a coding mistake:
The index 'handler' is used twice, but of course the second one will override the first one.
It does work as it is.
Comment #87
hass commentedwe need to fix this bug first
Comment #88
dunecat commentedHi everyone,
I would like to signal a little bug, after I ran the patch in 79.
Now in /admin/config/people/accounts, when I try to change the name for anonymous users, I get this error
I changed it in code, so it was not as big of an issue for me, but it was a bit of a surprise.
I am not sure, whether this issue needs to be addressed here, or in the core User module, or both.
Comment #89
jbfelix commented@pocketfluff #83
Here's the module
Don't forget the clear all cache after installation
Comment #90
WorldFallz commentedJust an FYI--
#83/#89 work... but the error prevents the field from being click sortable in views. The corrected code is:
Comment #91
jgullstr commentedBy disabling "Use formatted username" and "Link this field to its user" (due to
#1445404: Views: user name raw display is truncated) on the "User: Name" field settings, you can display the raw username without patches.
See here (#9) for linking the field to the user.
Edit: This starts throwing notices, see #1609088: Undefined index: uid in views_handler_field->get_value() (line 375 of views_handler_field.inc)
Comment #92
smartsystems160 commented#90 worked for me. Thanks guys
Comment #93
junaidpvMade #90 as a patch for this module.
Comment #94
sobi3ch commented#91 +1
Comment #95
oleksiy#91 - works for me
Comment #96
hass commentedWhy is this fundamental different to #79?
Comment #97
hass commentedComment #98
hass commentedBad news. I reviewed this patch and it seems working. BUT we are doing something wrong here. We try to add a workaround to realname, but I found the root cause of this bug in Views.
The buggy code is in [
views/modules/user/views_handler_field_user_name.inc]:What is wrong here? The conditions - very simple.
Why? Views has a checkbox inside usernames field that is named Use formatted username that is enabled by default. If you uncheck this setting the raw-username is still not shown. That is the bug in views. The reason is that the conditons are failing if the checkbox Link this field to its user is enabled. If you disable Link this field to its user and uncheck Use formatted username the raw-username is directly shown.
I will create a patch for views now and move the case than to Views for review.
Comment #99
jgullstr commented@hass
This is described in #91 - patch available in #1445404: Views: user name raw display is truncated
Comment #100
hass commentedThanks. So this is a duplicate here. After posting I also found that username theming is the root cause. I'm not entirely sure if we should not extend preprocess_username to allow themed username without forced username. At least it should be possible to dissble this behavior with an option like 'format_username' = FALSE.
Comment #101
wescleyteixeira commented#91 is the solution for this post ! Just do it!
Comment #102
alex.bukach commentedIndeed, #91 is the solution!