我一直在WordPress中使用各種自定義用戶字段(顯示在用戶個人資料中的字段)。隨着更新到3.4,這些字段不再保存到數據庫。客戶用戶字段不會保存在WordPress 3.4中
這是我一直在我的functions.php文件中使用的代碼。有沒有人知道需要改變這些工作在3.4?
// Create Custom User Fields
add_action('show_user_profile', 'appUserAnswers');
add_action('edit_user_profile', 'appUserAnswers');
function appUserAnswers($user) { ?>
<h3>Your Answers</h3>
<table class="form-table">
<tr>
<th><label for="question-1">Question 1</label></th>
<td>
<textarea type="text" name="question-1" id="question-1" class="regular-text" rows="5" cols="30"><?php echo esc_attr(get_the_author_meta('question-1', $user->ID)); ?></textarea>
</td>
</tr>
</table>
<?php }
// Save Custom User Fields
add_action('personal_options_update', 'appSaveUserAnswers');
add_action('edit_user_profile_update', 'appSaveUserAnswers');
function appSaveUserAnswers($user_id) {
if (!current_user_can('edit_user', $user_id))
return false;
// Copy and paste this line for additional fields. Make sure to change 'question-1' to the field ID.
update_usermeta($user_id, 'matrix-diagnosis', $_POST['question-1']);
}
我建議你用'vardump'檢查$ _POST中的內容。 – janw
謝謝@janw ...我會從那裏開始。 –
順便說一句,你在做什麼並不能節省$ _POST的價值 – janw