Update user’s xprofile input before it’s saved (I’m very close!)
-
Hi, I’d like to update what a user has inserted into an xprofile field before it is saved to the database using sanitize_key. I think I’m really close. Would really appreciate your help! With the current code, I get a 503 server error when I save a new value for the relevant fields.
In my 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);
- You must be logged in to reply to this topic.