0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
// テーマのfunctions.php // 編集者にユーザー追加・編集権限を与える function editor_add_caps() { $editor = get_role('editor'); $editor->add_cap('list_users'); $editor->add_cap('edit_users'); $editor->add_cap('create_users'); $editor->add_cap('delete_users'); $editor->add_cap('edit_theme_options'); $editor->add_cap('manage_options'); } if (current_user_can('editor') && !current_user_can('edit_users') ){ add_action('admin_init', 'editor_add_caps'); } |
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
// テーマのfunctions.php // 編集者にユーザー追加・編集権限を与える2 function editor_remove_caps(){ $editor = get_role('editor'); $editor->remove_cap('list_users'); $editor->remove_cap('edit_users'); $editor->remove_cap('create_users'); $editor->remove_cap('delete_users'); $editor->remove_cap('edit_theme_options'); $editor->remove_cap('manage_options'); } function editor_add_caps() { $editor = get_role('editor'); $editor->add_cap('list_users'); $editor->add_cap('edit_users'); $editor->add_cap('create_users'); $editor->add_cap('delete_users'); $editor->add_cap('edit_theme_options'); $editor->add_cap('manage_options'); } if ( current_user_can('editor') && current_user_can('edit_users') ){ add_action('admin_init', 'editor_remove_caps'); add_action('admin_init', 'editor_add_caps'); }elseif (current_user_can('editor') && !current_user_can('edit_users') ){ add_action('admin_init', 'editor_add_caps'); } |