2017-05-06 20 views
0

私はとても近づいていますが、間違いがあります。 私はWP wooCommerceのインストールに3つのカスタムフィールドを追加しました。フックとテンプレートを使って、登録とアカウントのページに追加しました。自分のプロフィールエリア/フロントエンドからユーザーとして正常に更新できます。 私が悩んでいるのは、編集ユーザー管理フォームでこれらのフィールドを更新していることです。フィールドを表示することはできますが、更新するだけではありません。WPユーザーのカスタムフィールドの更新を編集

考えと助けを探しています。私は何が欠けていますか?前もって感謝します。

これは私の子テーマのfunctions.phpで私のコードです - ADMIN編集USER

function sbb_custom_user_profile_fields($user) { 
?> 
<legend><h4>Reseller Info</h4></legend> 
<table class="form-table"> 
<tr> 
<th> 
    <label for="ssb_reseller_tax_id"><?php _e('Resseller Tax ID'); ?></label> 
</th> 
<td> 
    <input type="text" name="sbb_reseller_tax_id" id="sbb_reseller_tax_id" 
value="<?php echo esc_attr(get_the_author_meta('reseller_tax_id', $user->ID 
)); ?>" class="regular-text" /> 
</td> 
</tr> 
<tr> 
<th> 
    <label for="sbb_title"><?php _e('Title'); ?></label> 
</th> 
<td> 
<input type="text" name="sbb_title" id="sbb_title" value="<?php echo esc_attr(get_the_author_meta('title', $user->ID)); ?>" class="regular-text" /> 
</td> 
</tr> 
<tr> 
<th> 
    <label for="sbb_fax"><?php _e('Fax'); ?></label> 
</th> 
<td> 
    <input type="text" name="sbb_fax" id="sbb_fax" value="<?php echo esc_attr(get_the_author_meta('fax', $user->ID)); ?>" class="regular-text" /> 
</td> 
</tr> 
</table> 
<?php 
update_user_meta(get_the_author_meta($user->ID), 'reseller_tax_id', htmlentities($_POST[ 'reseller_tax_id' ])); 
update_user_meta(get_the_author_meta($user->ID), 'fax', htmlentities($_POST[ 'fax' ])); 
update_user_meta(get_the_author_meta($user->ID), 'title', htmlentities($_POST[ 'title' ])); 
} 

add_action('show_user_profile', 'sbb_custom_user_profile_fields'); 
add_action('edit_user_profile', 'sbb_custom_user_profile_fields'); 
add_action('edit_user_profile_update', 'sbb_custom_user_profile_fields'); 

答えて

0

私はあなたが投稿したコードを参照即時問題は、入力された名前を前置しています。 reseller_tax_idのメタキーで値を保存することができますが、入力名はsbb_reseller_tax_idです。これは、$_POSTで使用する必要がある入力名です。

$_POST[ 'reseller_tax_id' ])は、私は、フォームを提出し、あなたがそれを保存しようとする前に、入力の値を持っていることをされていることを確認することをお勧めしたい$_POST['sbb_reseller_tax_id'])

なります。ページを見るだけでは、更新を実行する効果がありません。

+0

ありがとうNathan - 私はそれを行ってあなたに知らせる – SIouxsie

関連する問題