【发布时间】:2021-02-16 08:55:43
【问题描述】:
我想更新用户在 3 个特定 xprofile 字段中插入的内容,并使用 sanitize_key 将其存储到数据库中(强制字母小写,删除除“-”和“_”之外的特殊字符)。当我回显它们时,这些值会改变我想要临时改变的方式,但不要存储在数据库中。
非常感谢您的帮助!这是我目前所拥有的
在我的functions.php中:
function expertise_tag_functions_before_save() {
global $bp;
foreach ($_REQUEST as $field => $value) {
if ($field == ‘field_24’ || $field == ‘field_26’ || $field == ‘field_27’) {
$value = sanitize_key( $value );
$field_label = str_replace(‘field_’, ”, $field);
xprofile_set_field_data($field_label, $user_id, $value);
}
}
};
add_action( ‘xprofile_data_before_save’, ‘expertise_tag_functions_before_save’, 10);
- 我已尝试将“xprofile_data_before_save”切换为“xprofile_data_after_save”,但仍然无效。
【问题讨论】:
标签: php wordpress buddypress