回答編集履歴
2
コメントの追加情報を受けて、コード追記
test
CHANGED
@@ -23,3 +23,37 @@
|
|
23
23
|
add_action('admin_menu', 'remove_menus');
|
24
24
|
|
25
25
|
```
|
26
|
+
|
27
|
+
--
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
**追記**
|
32
|
+
|
33
|
+
> もともとプラグインは管理者権限でしか表示されない
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
ということであれば、
|
38
|
+
|
39
|
+
functions.phpには、「編集者権限の時にメニューを追加する」コードを書くだけでいいはずです。
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
```PHP
|
44
|
+
|
45
|
+
function register_my_custom_menu_page() {
|
46
|
+
|
47
|
+
if (current_user_can('editor')) { //編集者だったらcart項目を表示
|
48
|
+
|
49
|
+
add_menu_page( 'custom menu title', 'カートアイコン', 'manage_options', 'admin.php?page=festi-cart', '', plugins_url( 'plugins/woocommerce-woocartpro/static/images/icon_16x16.png' ), 6 );
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
add_action( 'admin_menu', 'register_my_custom_menu_page' );
|
56
|
+
|
57
|
+
```
|
58
|
+
|
59
|
+
後、コメントに書かれたコードは、add_actionが関数内に記述されているために動作していません。
|
1
コード文法エラー修正
test
CHANGED
@@ -12,11 +12,7 @@
|
|
12
12
|
|
13
13
|
function remove_menus () {
|
14
14
|
|
15
|
-
if (!current_user_can('administrator' && !current_user_can('editor'
|
15
|
+
if (!current_user_can('administrator') && !current_user_can('editor')) { //管理者ではない かつ 編集者ではない場合
|
16
|
-
|
17
|
-
)) { //管理者ではない かつ 編集者ではない場合
|
18
|
-
|
19
|
-
|
20
16
|
|
21
17
|
remove_menu_page('festi-cart');
|
22
18
|
|