2017-05-06 20 views
0

그래서 가까이 왔지만 여기에 실수가 있어야합니다. WP wooCommerce 설치에 3 개의 사용자 정의 필드를 추가했습니다. 등록 및 내 계정 페이지에 후크 및 우 템플릿을 통해 추가했습니다. 프로필 영역/프런트 엔드에서 사용자를 성공적으로 업데이트 할 수 있습니다. 내가 갇힌 것은 편집 사용자 관리 양식에서이 필드를 업데이트하는 것입니다. 나는 필드를 표시 할 수 있지만 그들은 단지 업데이 트되지 않습니다.WP 사용자 정의 필드 업데이트 편집

생각과 도움을 찾고 있습니다. 내가 뭘 놓치고 있니? 미리 감사드립니다. 관리 사용자 편집

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

난 당신이 입력 이름을 접두어로하고 당신이 게시 한 코드를 함께 볼 수있는 즉각적인 문제 -

이 내 아이 테마의 functions.php 내 코드입니다. reseller_tax_id의 메타 키로 값을 저장할 수 있지만 입력 이름은 sbb_reseller_tax_id입니다. $_POST에서 사용해야하는 입력 이름입니다.

$_POST[ 'reseller_tax_id' ])

$_POST['sbb_reseller_tax_id'])

내가 양식을 제출하고 당신이 그것을 저장하는 시도하기 전에 입력 값을 가지고있다 것을 확인 좋을 것 될 것입니다. 페이지를 보는 것만으로 업데이트를 수행하면 안됩니다.

+0

감사합니다. Nathan - 나는 그것을 줄 것이고 당신에게 알려줄 것입니다. – SIouxsie

관련 문제