出现了相同的问题,并通过以下一点解决了此问题,即将所有新值放入保存为用户元数据的单个数组中:
//Where $access_key is the next (added) value
$get_access_keys_from_wp = get_user_meta($user_id,\'wsm_capability\');
$current_access_keys = $get_access_keys_from_wp[0];
$new_access_keys = array();
$new_access_keys[]=$access_key;
foreach($current_access_keys as $key => $value){
$new_access_keys[]=$value;
}
delete_user_meta( $user_id, \'wsm_capability\');//Clear out the meta data...
update_user_meta( $user_id, \'wsm_capability\', $new_access_keys);
保存/更新元密钥之前的数组(来自get\\u user\\u meta):
Array
(
[0] => access_9
)
结果数组(元更新后)添加“access\\u 5”的值:
Array
(
[0] => access_5
[1] => access_9
)
如果需要将新值添加到数组末尾,请执行以下操作:
//Where $access_key is the next (added) value
$get_access_keys_from_wp = get_user_meta($user_id,\'wsm_capability\');
$current_access_keys = $get_access_keys_from_wp[0];
$new_access_keys = array();
foreach($current_access_keys as $key => $value){
$new_access_keys[]=$value;
}
$new_access_keys[]=$access_key;
然后更新元。。。
布莱恩