私はwoocommerseショップのウェブサイトで作業しており、ユーザープロフィールページ内に性別フィールドを表示する必要があります。私はそれがWordpressのユーザープロファイルページ内の性別欄が表示されてwoocommerseに性別フィールドを追加するには
add_action('show_user_profile', 'show_extra_profile_fields');
add_action('edit_user_profile', 'show_extra_profile_fields');
function show_extra_profile_fields($user) { ?>
<h3>Extra profile information</h3>
<table class="form-table">
<tr>
<th><label for="gender">Gender</label></th>
<td>
}
<select name="gender" id="gender" >
<option value="Male" <?php selected('Male', get_the_author_meta('gender', $user->ID)); ?>>Male</option>
<option value="Female" <?php selected('Female', get_the_author_meta('gender', $user->ID)); ?>>Female</option>
</select>
</td>
</tr>
</table>
<?php }
add_action('personal_options_update', 'save_extra_profile_fields');
add_action('edit_user_profile_update', 'save_extra_profile_fields');
function save_extra_profile_fields($user_id) {
if (!current_user_can('edit_user', $user_id))
return false;
update_usermeta($user_id, 'gender', $_POST['gender']);
}
のfunctions.phpには、次のコードを追加しようとしたが、していないwoocommerceユーザープロファイルページ内。
これは可能ですか?
ありがとうございます。
あなたがそれに満足しているなら、他の人もそれを見つけることができるように答えを正しいものとして記入してください。 :-) - – Lutrov
はい、これは完全に動作しています。非常に@ Lutrovありがとう! –
こんなにありがとうございました。 – HollerTrain