WordPressプラグイン User Role Editor を利用した際に、ユーザーの追加・編集画面に表示される「他の権限グループ」の表示を消す方法についてご紹介します。
目次
User Role Editor
WordPress.org 日本語


User Role Editor
User Role Editor WordPress プラグインはユーザーの種類と権限を簡単に変更できます。WordPress ユーザーの種類と権限の 編集/追加/削除。
User Role Editor は、WordPressのユーザー権限の種類(権限グループ)を追加したりその設定を変更したりするプラグインです。
様々な機能がありますが、有効化した際にユーザー追加・編集画面に「他の権限グループ」という設定が追加されます。
「このユーザーの追加の権限を選択する」とあるように、
この機能を使うと、「編集者」かつ「総務部」というような複数の権限を持つユーザーを作成できます。

「他の権限グループ」の表示を消したい
複数の権限グループの利用を想定しないなど、この機能が表示されないほうが良い場合もあります。
権限グループとわず消したい
ure_show_additional_capabilities_section フィルタが falseを返すようにすれば「他の権限グループ」の表示が消えます。
add_filter('ure_show_additional_capabilities_section', 'ure_show_additional_capabilities_section');
function ure_show_additional_capabilities_section() {
return false;
}
権限グループによって表示・非表示を切り替えたい
current_user_can(‘権限グループ名’)でユーザーの権限グループを判断できます。
消したい権限グループの時だけfalseを返すようにしましょう。
add_filter('ure_show_additional_capabilities_section', 'ure_show_additional_capabilities_section');
function ure_show_additional_capabilities_section($show) {
if (current_user_can('administrator')) {
$show = false;
}
return $show;
}
これで「他の権限グループ」の表示を消すことができました。

参考:https://www.role-editor.com/forums/topic/hide-other-roles-control/
コメント