WordPressで、あるユーザ権限(購読者)だけパスワード変更できないようにするには
本当にこんな運用をするかどうかは別にして、あるユーザ権限(購読者)だけパスワードを変更させないようにすることができる。
の最後にあるコードをテンプレート中のfunctions.phpを入れてみたのだが、3.2.1 ではうまく動かなかった。
どうも、 $current_user->user_level や他サイトにある、 global $user_level というのが未定義からのようで、以下のように変更したところうまくいった。
function update_password_fields($show_password_fields) { global $current_user; get_currentuserinfo(); if ($current_user->roles[0] == 'subscriber') { print "<p>If you want to change the password, please tell your administrator what you want.</p>"; } else { return $show_password_fields; } } add_filter('show_password_fields', 'update_password_fields');