質問編集履歴
2
ソースタグへ変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -54,25 +54,27 @@
|
|
54
54
|
|
55
55
|
**Contact Form 7 上**
|
56
56
|
|
57
|
+
・ラジオボタン
|
57
58
|
|
58
|
-
|
59
|
-
|
59
|
+
```php
|
60
60
|
|
61
61
|
[radio sex use_label_element "男" "女"]
|
62
62
|
|
63
|
-
|
63
|
+
```
|
64
64
|
|
65
65
|
・セレクトボタン
|
66
66
|
|
67
|
+
```php
|
68
|
+
|
67
69
|
[select* kinmuchi class:form-control "北海道" "青森県" 〜と都道府県リストを記載 ]
|
68
70
|
|
69
|
-
|
71
|
+
```
|
70
72
|
|
71
73
|
|
72
74
|
|
73
75
|
**個別記事テンプレート(Contact Form 7 へhiddenでデータ渡す**
|
74
76
|
|
75
|
-
|
77
|
+
```php
|
76
78
|
|
77
79
|
$user = wp_get_current_user();
|
78
80
|
|
@@ -90,11 +92,15 @@
|
|
90
92
|
|
91
93
|
</form>
|
92
94
|
|
95
|
+
```
|
96
|
+
|
97
|
+
|
98
|
+
|
93
99
|
|
94
100
|
|
95
101
|
**functions.php**
|
96
102
|
|
97
|
-
|
103
|
+
```php
|
98
104
|
|
99
105
|
function my_form_tag_filter($tag){
|
100
106
|
|
@@ -134,7 +140,7 @@
|
|
134
140
|
|
135
141
|
add_filter('wpcf7_form_tag', 'my_form_tag_filter');
|
136
142
|
|
137
|
-
|
143
|
+
```
|
138
144
|
|
139
145
|
|
140
146
|
|
1
ソースの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -48,6 +48,98 @@
|
|
48
48
|
|
49
49
|
|
50
50
|
|
51
|
+
### 実際のソース
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
**Contact Form 7 上**
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
・ラジオボタン
|
60
|
+
|
61
|
+
[radio sex use_label_element "男" "女"]
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
・セレクトボタン
|
66
|
+
|
67
|
+
[select* kinmuchi class:form-control "北海道" "青森県" 〜と都道府県リストを記載 ]
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
**個別記事テンプレート(Contact Form 7 へhiddenでデータ渡す**
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
$user = wp_get_current_user();
|
78
|
+
|
79
|
+
$sex = $user -> sex;
|
80
|
+
|
81
|
+
$kinmuchi = $user -> kinmuchi;
|
82
|
+
|
83
|
+
<form action="<?php echo esc_url( home_url( '/entry/' ) ); ?>" method="post">
|
84
|
+
|
85
|
+
<input type="hidden" name="sex" value="<?php echo $sex; ?>">
|
86
|
+
|
87
|
+
<input type="hidden" name="kinmuchi" value="<?php echo $kinmuchi; ?>">
|
88
|
+
|
89
|
+
<div class="entry-button"><input type="submit" value="エントリーする"></div>
|
90
|
+
|
91
|
+
</form>
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
**functions.php**
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
function my_form_tag_filter($tag){
|
100
|
+
|
101
|
+
if ( ! is_array( $tag ) )
|
102
|
+
|
103
|
+
return $tag;
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
if(isset($_POST['sex'])){
|
108
|
+
|
109
|
+
$name = $tag['name'];
|
110
|
+
|
111
|
+
if($name == 'sex')
|
112
|
+
|
113
|
+
$tag['values'] = (array) $_POST['sex'];
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
if(isset($_POST['kinmuchi'])){
|
120
|
+
|
121
|
+
$name = $tag['name'];
|
122
|
+
|
123
|
+
if($name == 'kinmuchi')
|
124
|
+
|
125
|
+
$tag['values'] = (array) $_POST['kinmuchi'];
|
126
|
+
|
127
|
+
}
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
return $tag;
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
add_filter('wpcf7_form_tag', 'my_form_tag_filter');
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
51
143
|
### 補足情報(FW/ツールのバージョンなど)
|
52
144
|
|
53
145
|
|