PDA

View Full Version : Change Username Hack


Scott MacVicar
08-04-2001, 11:32 PM
I wrote a small modification to allow users to change their usernames, they can change their username ok and post at the forums etc.

BUT when they go to view a forum where only admins and moderators can post they get the standard No Permissions or You need to be registered error.

Dennis Wrenn
08-05-2001, 12:16 AM
Well, that's perfectly normal. If the forum is only for Administrators and Moderators, then they shouldn't be allowed to view it.

Do you want them to be able to view - but not post in the forum?

Scott MacVicar
08-05-2001, 12:41 AM
sorted now :)

i had it set on private forum =/

Admin
08-06-2001, 04:47 AM
Can you release your hack?
It sounds nice, and very useful. :)

Scott MacVicar
08-06-2001, 05:48 AM
Instructions are in the file. Isn't too hard to install.

If you need any help just post back here.

Look at http://vbulletin.com/forum/showthread.php?s=&threadid=24722 latest verion from there

RobAC
08-06-2001, 06:50 AM
If a user has...say....20 posts, and they go and change their username, do all their posts automatically update with the new username? If you have a members only board with a lot of members and you have several members changing their usernames, you're probably going to have problems with posts having invalid usernames, etc., unless you periodically update user info, post counts, etc., via the Admin CP.

Admin
08-06-2001, 07:21 AM
The user's ID does not change. Everything the user has posted before is associated with his ID, including his username.
So yes, all of past posts and everything else will have the new username.

Scott MacVicar
08-06-2001, 07:25 AM
Nope, only the user ID is stored in the thread table not the Username. So when the username changes, it changes it for all posts made by the user.

Dimitri
08-06-2001, 08:14 AM
I get the following error after applying the hack to member.php:

Parse error: parse error in /---removed---/member.php on line 1298

I am using 2.0.3 so I'm not sure if that's the problem.

Admin
08-06-2001, 08:25 AM
Dimitri, this is the code you will need to paste:
if ($username != $bbuserinfo[username]) {
$username = trim($username);
$username = eregi_replace("( ){2,}", " ", $username);
if ($checkuser=$DB_site->query_first("SELECT username FROM user WHERE username='".addslashes(htmlspecialchars($username))."' OR username='".addslashes(eregi_replace("[^A-Za-z0-9]","",$username))."'")) {
eval("standarderror(\"".gettemplate("error_usernametaken")."\");");
exit;
}
}
else {
$DB_site->query("UPDATE user SET username='".addslashes(htmlspecialchars($username))."' WHERE userid='$bbuserinfo[userid]'");
$bbuserinfo[username] = $username;
}
PPN forgot to close one IF statement.

Scott MacVicar
08-06-2001, 08:37 AM
my bad :p

updated txt file and reloaded it

i just copied and pasted from my member.txt file, never bothered to check the code i had copied -_-

thanks for pointing it out firefly

Admin
08-06-2001, 08:57 AM
No problem. :)

Great hack, you should release it! :D

Dakota
08-06-2001, 03:39 PM
Is there a way that you could require a certain post count before a user can change their name?

Scott MacVicar
08-06-2001, 07:19 PM
ok updated so you can set a amount of posts needed before they can change username, look at

http://vbulletin.com/forum/showthread.php?s=&threadid=24722

for latest version

Wayne Luke
08-06-2001, 09:14 PM
Hmmm doesn't leave a whole lot of consistency..

Anyway, you don't need a Hack for this. You should require at least one field (username) to remain constant. You can then give the members a display name which they can change at will. All without hacking needed at all.

Go into the Admin Control Panel and scroll down to the User Profile Field section.

Create a new field called display name and make it required.

Then edit your templates to display this value instead of the username.

Same effect, no hacking, no mess.

It will require hacking to change it based on posts though.

Santa
08-07-2001, 05:16 AM
Can u please tell me, which templates I must edit ??? I think this will be not only one or two :) ?

Many Thx


Santa

Admin
08-07-2001, 06:03 AM
You need to edit the postbit template.

Santa
08-07-2001, 06:06 AM
many thx for this fast answer

Santa