私のプラグインコードは以下のようになります。
if (!current_user_can('administrator')){
function hide_post_page_options() {
//global $post;
// Set the display css property to none for add category and add tag functions
$hide_post_options = "<style type=\"text/css\"> .jaxtag { display: none; } #category-adder { display: none; } </style>";
print($hide_post_options);
}
add_action( 'admin_head', 'hide_post_page_options' );
}
しかし、アクティブ化するとエラーが発生します
Fatal error: Call to undefined function wp_get_current_user()
capabilities.php に pluggable.php を含めることで、これを回避できます。しかし、これらのファイルを変更することがより良い方法だとは思いません。wp_get_current_user() はプラグ可能な関数であるため、プラグインがロードされた後にのみ使用できます。コアファイルを変更せずにこれを使用する方法はありますか?