Hello all,
If you're like me, and very paranoid then this may help you :P. It stops people [With the correct permissions] from deleting your account on your forums. To do this find:
function deleteMembers($users)
{
global $db_prefix, $sourcedir, $modSettings, $ID_MEMBER;
In Sources/ManageMembers.php (/Sources/Subs-members.php in SMF 1.1)
and replace it with:
function deleteMembers($users)
{
global $db_prefix, $sourcedir, $modSettings, $ID_MEMBER;
// Protect the person who started the forum
if ($users == 1 or @in_array(1, $users))
fatal_error('You\'re not allowed to delete the administrator.');
This stops people from deleting your account either through your profile, or through the view/delete members page in the admin panel.
If you're ID isn't 1, but you still want to protect yourself, then just change the 2 numbers in this part:
if ($users == 1 || (is_array($users) && in_array(1, $users)))
to whatever your member ID is.
If you want this to not extend to more than one user, you can do so by doing what JohnyB (http://www.simplemachines.org/community/index.php?action=profile;u=67763) suggested:
// Protect the person who started the forum
if ($users == 1 or $users == 2 or @in_array(1, $users) or @in_array(2, $users))
fatal_error('You\'re not allowed to delete the administrator.');
I hope this helps someone.
TauOnline.Org (http://tauonline.org)
Keep in mind this only works if the Admin is member number one. In my case, (an upgraded board that had a 'dummy' admin set up as member number one) I need to change it slightly.
Quote from: Amacythe on September 11, 2004, 10:23:49 AM
Keep in mind this only works if the Admin is member number one. In my case, (an upgraded board that had a 'dummy' admin set up as member number one) I need to change it slightly.
Yeah it's easy to change though :) I'll edit my post just to show how to do it if people don't know.
Quote from: Tau Online on September 11, 2004, 09:56:11 AM
if ($users == 1 xor in_array(1, $users) )
Just wondering; is there a particular reason you're using xor here? It's different from or in that it means one OR the other, but not BOTH. In this case, it really *couldn't* be both, but or (||) should work too....
-[Unknown]
Quote from: [Unknown] on September 11, 2004, 03:28:08 PM
Quote from: Tau Online on September 11, 2004, 09:56:11 AM
if ($users == 1 xor in_array(1, $users) )
Just wondering; is there a particular reason you're using xor here? It's different from or in that it means one OR the other, but not BOTH. In this case, it really *couldn't* be both, but or (||) should work too....
-[Unknown]
Your right! Thanks, I'll change it now :) It wouldn't make a difference though would it? (I mean whether xor or || is used?)
Nope, none really in this case.... although, I prefer "||" over the word form "or".... then again I like C/C++ ;).
-[Unknown]
Dont' want to be a pain, but is there a way to keep users from deleting their own accounts? I hate when people do that.
It's a permission. Simply disallow it.
-[Unknown]
This doesn't seem to work with SMF 1.0.1 Final :'(
I get this error :
2: in_array(): Wrong datatype for second argument
File: /home/sol/public_html/forum/Sources/ManageMembers.php
Line: 984
Line 984 :
if ($users == 1 || in_array(1, $users) )
I've used this trick twice before with RC2 and it's worked fine. I've copied everything exactly right.
Quote from: Sol on January 27, 2005, 11:56:38 AM
This doesn't seem to work with SMF 1.0.1 Final :'(
I get this error :
2: in_array(): Wrong datatype for second argument
File: /home/sol/public_html/forum/Sources/ManageMembers.php
Line: 984
Line 984 :
if ($users == 1 || in_array(1, $users) )
I've used this trick twice before with RC2 and it's worked fine. I've copied everything exactly right.
It's not updated to work with SMF 1.0(.1) I'll update it sometime :)
As soon as possible please :P
working fix for 1.03 (tested) just quoted TauOnline and edited it :)
find in Sources/ManageMembers.php
function deleteMembers($users)
{
global $db_prefix, $sourcedir, $modSettings, $ID_MEMBER;
In Sources/ManageMembers.php
and replace it with:
function deleteMembers($users)
{
global $db_prefix, $sourcedir, $modSettings, $ID_MEMBER;
// Protect the person who started the forum
if ($users == 1)
{
fatal_error('You\'re not allowed to delete the administrator.');
exit();
}
This stops people from deleting your account either through your profile, or through the view/delete members page in the admin panel.
If you're ID isn't 1, but you still want to protect yourself, then just change the number.
Am I the only one that's scared to test this mod out? >>
I've updated my first post so this now works with updated versions (Tested with 1.1 Beta 3 and 1.0.5)
Credit goes to [Unknown] for this update, he posted an updated/working version of this hack in one of the threads in the Announcements board.
Quote from: Jako on June 26, 2005, 04:59:20 AM
Am I the only one that's scared to test this mod out? >>
:P I was at first. Either backup your database or run SMF on a test server.. It should work though.
Quote from: Jako on June 26, 2005, 04:59:20 AM
Am I the only one that's scared to test this mod out? >>
you can do what TAU said above or you can also change the user number in the code above. :)
instead of "1" (whcih is the admin) change it to another one, like a member that you're about to remove.
Dude, I have SMF 1.1 Beta 3 but I can't find the code...
Is there something I'm missing???
It's in Subs-Members.php.
-[Unknown]
how about if i want to protect two or more accounts?
can i just add comma to the number like if ($users == 1,2 xor in_array(1,2 $users) )
by the way, which one of the two codes would work for 1.0.5? could you please label those codes with the versions that it would work with?
thank you! :D
No, you can't just add commas like that. Instead:
if ($users == 1 or $users == 2 or @in_array(1, $users) or @in_array(2, $users))
Would probably be best.
-[Unknown]
so if it's three users, i just add more "or"s?
something like this?
if ($users == 1 or $users == 2 or $users == 36 or @in_array(1, $users) or @in_array(2, $users) or @in_array(3, $users))
Quote from: malinaobenny on August 27, 2005, 01:28:31 PM
so if it's three users, i just add more "or"s?
something like this?
if ($users == 1 or $users == 2 or $users == 36 or @in_array(1, $users) or @in_array(2, $users) or @in_array(3, $users))
That would be correct, yes.
Quote from: malinaobenny on August 27, 2005, 01:28:31 PM
so if it's three users, i just add more "or"s?
something like this?
if ($users == 1 or $users == 2 or $users == 36 or @in_array(1, $users) or @in_array(2, $users) or @in_array(3, $users))
Shouldn't that be:
if ($users == 1 or $users == 2 or $users == 36 or @in_array(1, $users) or @in_array(2, $users) or @in_array(
36, $users))
?? Don't know myself, just curious?
Greetz!
Quote from: Anakin_holland on August 27, 2005, 02:23:07 PM
Shouldn't that be:
if ($users == 1 or $users == 2 or $users == 36 or @in_array(1, $users) or @in_array(2, $users) or @in_array(36, $users))
?? Don't know myself, just curious?
Greetz!
Yeah, I presumed the original "3" was just a typo.
I have a question. Couldn't they just ban you? It would end in the same effect. Could someone make it so they can't ban or demote u?
Quote from: Libo on November 08, 2005, 09:58:47 PM
I have a question. Couldn't they just ban you? It would end in the same effect. Could someone make it so they can't ban or demote u?
True, but a ban or demotion is reversable... ;) and the effect isn't exactly the same, because the messages will still be attached to that banned or demoted user?
Greetz!
Support me here: Super admin (http://www.simplemachines.org/community/index.php?topic=53498.0) ;)
Maybe if much people asks for it, they give :P
Pepsi! Ask for more! LOL
okay, cool
couldnt you just check if the user is administrator and then disable deletion?
Quote from: [Unknown] on January 25, 2005, 06:45:40 PM
It's a permission. Simply disallow it.
-[Unknown]
As far as removing the ability of a member to delete their account, I can't find it in the permissions to disallow. Where is it?
Quote from: leesw on January 02, 2006, 07:38:12 PM
Quote from: [Unknown] on January 25, 2005, 06:45:40 PM
It's a permission. Simply disallow it.
-[Unknown]
As far as removing the ability of a member to delete their account, I can't find it in the permissions to disallow. Where is it?
using 1.1?
- admin>permissions>modify>uncheck delete account:own account
1.05?
- admin>edit permissions>modify>uncheck delete account:own account
Thank you azuregenesis!
What is code for SMF 1.0.5. ?
Hi there,
I was about to add this to my site.
Just wanted to ask, is this till valid for version 1.1 RC2? or does that version already have this kind of feature?
I can find the code no problem but just wondered if this was a needed mod to add.
function deleteMembers($users)
{
global $db_prefix, $sourcedir, $modSettings, $ID_MEMBER;
What's the code for version 1.1 RC2?
The one for smf 1.1...
Glad this came back up. I had forgotten to had it back after updating to 1.1 RC2 ;D ;)
Quote from: DemonicInfluence on June 18, 2006, 06:49:39 PM
The one for smf 1.1...
So the code for smf 1.1 is compatible if you use 1.1 RC2? Are you sure?
yes..
This works great, thanks!
Im member #1, but I have a spy that I use on the forum and act like a regular member, just to see ways people act and stuff. How would I make both undeleteable?
[EDIT]
Removed all the code from here. I have packaged this as a mod now and should be available shortly (once approved) here at SMF as "Admin Deletion Protect" mod.
In the interim, if you want this right away, you can find it at my TP Blocks (http://www.tpblocks.com) site available for download. Downloading requires registration however.
Quote from: Stuart on July 08, 2006, 08:17:53 PM
This works great, thanks!
It's no longer working with SMF 1.1.1 though :'(
I can't found the code what i am looking for in the file. I am running with 1.1.1 with TP.
I would also like to make use of this code edit.
SMF 1.1.2 w/Tiny Portal 0.9.7.1
Yes would be nice to have this updated for 1.1.2 ;)
Would be nicer to have this as a fixed option of enable or disabled in SMF Admin panel ;D
I updated the hack. You can find a working version, including the fix for the Profile page to prevent removing from the Admin group, at my TP Blocks site (http://www.tpblocks.com). The post is located here (http://www.tpblocks.com/index.php?topic=67.msg182#msg182) and is accessable to guests as well.
Quote from: Thurnok on April 29, 2007, 07:41:22 AM
I updated the hack. You can find a working version, including the fix for the Profile page to prevent removing from the Admin group, at my TP Blocks site (http://tpblocks.ccs-net.com). The post is located here (http://tpblocks.ccs-net.com/index.php?topic=67.msg182#msg182) and is accessable to guests as well.
It appears that guest access is not available, when I clicked the link it presents me with a registration box. :(
Sorry, caught me in the middle of moving my site as well. Try going to the new site (updated in my original post) and you should now be able to access it.
Quote from: Thurnok on April 30, 2007, 10:06:17 PM
Sorry, caught me in the middle of moving my site as well. Try going to the new site (updated in my original post) and you should now be able to access it.
hi,
I noticed that the site was under maintenance later last night, thanks for the reply, i'll try again now.
Regards
I've packaged this up as a Mod and it has now been submitted to SMF, just waiting approval.
I applied the mods from your site on may 1st, it works very well indeed.
But pleased to see you have made a package.
Regards
Quote from: Thurnok on May 05, 2007, 05:47:43 PM
I've packaged this up as a Mod and it has now been submitted to SMF, just waiting approval.
Is this mod not available for downloading yet? It will be nice if it will work with SMF 1.1.3 ;)
Ok, tested with SMF 1.1.3 and it works. It won't delete user #5 and #6. Then I deleted #9 and it deleted it. Thank you.
// Protect the person who started the forum
if ($users == 5 or $users == 6 or @in_array(5, $users) or @in_array(6, $users))
fatal_error('You\'re not allowed to delete the administrator.');
is anyone using this on 1.1.4?
The same method JohnyB has posted above would work for 1.1.4.
You will find little differences between 1.1.3 and 1.1.4 as once we released the 1.1 line it was only bug patches and security fixes we are doing :)
nice thks a lot
Anyone have any further info on this working with 1.1 RC3?? I tried inserting the code into Subs-Members.php and then tried deleting the named admin and it allowed me to...
I've updated my first post to reflect JohnyB's suggested code change :)
A couple other questions, is it possible to disable ban of yourself and disable admin membergroup remove of yourself?
Wat about smf 1.1.5
It should work.
Can some one give me the exact code for smf 1.1.5
As i didnt find what i need to change
Quote from: brianjw on July 02, 2008, 07:40:28 PM
A couple other questions, is it possible to disable ban of yourself and disable admin membergroup remove of yourself?
That feature would be quite useful
Quote from: double_d on January 25, 2005, 05:40:46 PM
Dont' want to be a pain, but is there a way to keep users from deleting their own accounts? I hate when people do that.
Totally agree :P
Does this work for SMF 1.1.7??
Am curious, as I was going to use it but I am not finding any of the quoted code from the first post, in the stated files.
Any help appreciated :):)
Thanks :)
I use it with 1.1.7. Look on Line 113 of Sources/Subs-Members.php (note that this assumes the file has not been altered since installation).
thank you so much!!
found it right where you said to look
no idea why it wasnt showing up when i did a search for it in the actual php file ???
anywho.. thank you for the help, appreciate it :):)
Anybody know what to do for 2.0 RC4? I'm sure it can be done but I'm not qualified to mess around with it. I could really use this.
Thanks for the information!
I assume 2.0 RC4 is similar to RC5. :-[ I looked in Sources/Subs-Members.php and replace this line:
function deleteMembers($users, $check_not_admin = false)
{
global $sourcedir, $modSettings, $user_info, $smcFunc;
with the following:
function deleteMembers($users, $check_not_admin = false)
{
global $sourcedir, $modSettings, $user_info, $smcFunc;
// Protect the person who started the forum
if ($users == 1 or @in_array(1, $users))
fatal_error('You\'re not allowed to delete the administrator.');
Once the code was installed, I tried to delete myself (after making a backup of the database ;) ). The "not allowed" message came up.... I hope this helps.
Anyone knows how to do this on 2.0?
Check the post above yours..
function deleteMembers($users, $check_not_admin = false)
{
global $sourcedir, $modSettings, $user_info, $smcFunc;
Is nowhere in subs-members.php
It is for me.. o_O Check +/- line 85
Oh now i found it ;D Thanks
Thanks, I just made the edits given in post #70. Now how do I test it without deleting myself if it doesn't work? Would my bco-admin be able to reinstate me and reassign me all my posts etc?
Edit: Doh! I made an additional admin account, changed the numbers and tested by deleting that second admin account. I found out this mod works great, as long as you don't use it in conjunction with the quick ban on delete mod - it doesn't seem to protect me from being banned :P
Great tip thanks for sharing