This patch makes only selected users able to change their username

Comments

walkah’s picture

+1 for the functionality! (not sure about the permission name).

saerdna’s picture

Status: Needs review » Needs work
StatusFileSize
new2.02 KB

With this patch, users who has the "change own username" flag can change their own username. users with administer users can still change own/others usernames.

What needs to be done on this patch?

Currently the patch only hides the form input. There need to be some check in the validation but im not sure how to make it. I dont want to mess the validate_name function because its supposed to validate the name not the access imo.

Also im not sure if people with "administer users" can change user with uid 1 username. this should not be possible. (it shouild not be possible to change the uid 1 user at all if you are not the one imo).

Would be great if someone can complete this.

rkerr’s picture

In the _user_edit_validate function, I think you will have to wrap the section that validates the username (around line 1185 .. 1193 of user.module in the cvs tarball I just downloaded) with your access privileges check.

Such as:

if (can change username)
  validate username
else
  unset edit['name']
end if
Crell’s picture

Status: Needs work » Needs review
StatusFileSize
new3.62 KB

I'll help with this, since I'm a big fan of more finely grained permissions. :-)

Yep, that's all that was needed. Here's an updated version that should be fully functional. I also got rid of the tab character in favor of the preferred double space.

saerdna’s picture

Status: Needs review » Reviewed & tested by the community

thanks crell!

im not used with all of the drupal codingstandards, ill config my editor for 2 spaces :-)

and the patch seems to work great!

i tried to make a form in a static html on the hardrive and post it to my drupalsandbox but it got denied :)

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)
pancho’s picture

Version: » 4.7.0

Adding version tag