dekirukun
フォーラムへの返信
2件の返信を表示中 - 1 - 2件目 (全2件中)
-
フォーラム: 使い方全般
返信が含まれるトピック: ユーザー>プロフィール項目の追加項目でチェックボックスを利用したいJunko Nukagaさま ありがとうございます。
例をコピペして、プロフィール情報へ追加項目でチェックボックスを表示することができました。
/** * Show custom user profile fields * @param obj $user The user object. * @return void */ function numediaweb_custom_user_profile_fields($user) { ?> <table class="form-table"> <tr> <th width="21"> <label for="tc_location">お手本<?php _e('Location'); ?></label> </th> <td width="268"> <input type="text" name="tc_location" id="tc_location" value="<?php echo esc_attr( get_the_author_meta( 'tc_location', $user->ID ) ); ?>" class="regular-text" /> <br><span class="description"><?php _e('お手本', 'travelcat'); ?></span> </td> </tr> <tr> <th> <label for="label_dpc"><?php _e('左ラベル', 'DPC'); ?></label> </th> <td> <span class="description">これを作成<?php _e('説明文', 'dpc'); ?></span><BR /> <input type="checkbox" name="dpc" value="<?php echo esc_attr( get_the_author_meta( 'dpc1', $user->ID ) ); ?>"/> <label for="checkbox">DPC1</label><BR /> <input type="checkbox" name="dpc" value="<?php echo esc_attr( get_the_author_meta( 'dpc2', $user->ID ) ); ?>"/> <label for="checkbox">DPC2</label><BR /> <input type="checkbox" name="dpc" value="<?php echo esc_attr( get_the_author_meta( 'dpc3', $user->ID ) ); ?>"/> <label for="checkbox">DPC3</label><BR /> </td></tr> </table> <?php } add_action('show_user_profile', 'numediaweb_custom_user_profile_fields'); add_action('edit_user_profile', 'numediaweb_custom_user_profile_fields');
上記の様にして、「プロフィールを更新」を押しても値が保存されませんでした。
下記の様な記入が必要なのかな?と上記の下に追記をして試してみましたが、値を更新して保存/表示を行うにはどのようなことが必要でしょうか?
add_action('edit_user_profile_update', 'update_extra_profile_fields'); function update_extra_profile_fields($user_id) { update_user_meta($user_id, 'dpc', $_POST['dpc']); }
フォーラム: 使い方全般
返信が含まれるトピック: twenty twelve 子テーマ作成で wedget-area・・・困った
2件の返信を表示中 - 1 - 2件目 (全2件中)