For a few weeks some wise guy decided that it will be fun if he will change password to WPJobBoard demo account randomly about twice a week. Well, it wasn’t fun at all. At least for most people, so i decided that i need a plugin to disable profile update. More over i wanted to disable user, so he cannot “edit himself”.
Like you probably already guessed i wrote a plugin for that, it’s just few lines of code, so i will just paste it here:
function lockdown($user_id) { global $current_user; wp_redirect("profile.php"); } add_action('personal_options_update', "lockdown");
It’s a bit simplified version of what i am using, either way what it does is pretty much this, when someone will try to edit his profile he will be redirected to profile page, without any notification.
Note two things: while even admin won’t be able to edit his profile, he will still be able to edit other users profiles. If you would like to disable last mentioned functionality add this line to the code above:
add_action('edit_user_profile_update', "lockdown");





7 Comments on "Disable WordPress profile edition"
Very good things. But I want to make a community blog where people cant able to change their nick name. only the nick name. nothing else. how can i do this.?
Hi
Where do I need to paste this code?
I have a custom site with an user “ticket” and and a password that I change every 2 days.
this user, “ticket” may not be able to change his password
It’s a WordPress plugin, you can read more about developing plugins at http://ditio.net/2007/08/09/how-to-create-wordpress-plugin-from-a-scratch/
—————–
but face
Fatal error: Cannot redeclare lockdown() (previously declared in C:\xampp\htdocs\blog\wp-content\plugins\login-lockdown\loginlockdown.php:146) in C:\xampp\htdocs\blog\wp-content\plugins\lockdown\lockdown.php on line 14
Hey Greg you thought to help others by creating a code about to stop editing users profile which is really good to stop spam kind of things.. But if you review the comments below they are asking the same kind of help for other purpose and someone tried the code and facing some errors like the errors ma7aba star mentioned in his comment.. Why don’t you contact them and tell the exact way to get rid of those errors… So that they will be following you and sometimes they can assist you for other affairs…
Venkatesh – Gulfwebstudio.com
hey great plugin, jut wondering how could i manage if I just want to disable edditing the email field??? thanks man!
I actually was looking for something just like this. Thanks.
We have been trying to do this exact same thing, to prevent the issue you had with the demo account.
You can add one extra step to the plugin, however. I made a custom role for Demo Accounts, and set a couple of capabilities that are to limit their use.
For instance, I added a capability called “no_account_access”, so with that ability you can do something like this instead:
[code]
function lockdown($user_id)
{
if ( current_user_can ( 'no_account_access' ) ) {
wp_redirect(get_bloginfo('url')); exit;
}
}
add_action('personal_options_update', "lockdown");
[/code]
Now, the Admin can still edit their own profile, and anyone else can edit their own profile, but only the users with the role/capability of ‘no_account_access’ can’t edit their own profile.