Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to disable changing password option for all my subscriber users.

Is it possible by doing any code tweak or something using any plugin?

Disable password changing option for subscriber users

If someone has any idea or plugin knowledge to do this then appreciated.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

You can try

if( current_user_can( 'subscriber' ) ) {
    add_filter( 'show_password_fields', '__return_false' );
}

see also http://wpengineer.com/2285/disable-password-fields-for-non-admins/

http://adambrown.info/p/wp_hooks/hook/show_password_fields

share|improve this answer
    
where do i put this code? in any theme specific file? In functions.php right. –  Frank Apr 8 '13 at 8:02
    
Yes, here (and in most case when you need to add code), it's likely to be in functions.php. Never tweak core files, unless you knwo what you're doing. –  user29296 Apr 8 '13 at 8:24
    
Thanks, you made my day. –  Frank Apr 8 '13 at 8:46

If you want to hide the passwords fields on the profile page, you can use the show_password_fields filter

add_filter('show_password_fields','hide_password_wpse_94968');
function hide_password_wpse_94968() {
    if(!current_user_can('edit_posts')){
        // hide only for subscribers
        return false;
    }
    return true; // for all other users that can edit posts
}

where we hide it for all users that can't edit posts (subscribers).

The subscribers will still be able to retrieve new passwords via wp-login.php?action=lostpassword.


Before hiding the passwords fields:

Before hiding


After hiding the passwords fields:

enter image description here

share|improve this answer
    
Thanks for the help. I got it. –  Frank Apr 8 '13 at 8:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.