function save_new_fields($user_id) { if (!current_user_can('edit_user', $user_id)) { return false; } update_user_meta($user_id, 'datr_plugin_language', $_POST['datr_language']); if (!current_user_can('manage_options')) { return false; } $topics = EventDatabaseManager::getAllTopics(); foreach ($topics as $id => $title) { if (isset($_POST['user_has_topic_' . $id])) { $topicParams = array(); foreach (EventDatabaseManager::$userHasTopicsParams as $param) { $topicParams[$param] = $_POST[$param . '_' . $id]; } EventDatabaseManager::addOrUpdateAssignedTopic($user_id, $id, $topicParams); } else { EventDatabaseManager::deleteAssignedTopic($user_id, $id); } } $locations = EventDatabaseManager::getMandantLocations(get_user_meta($user_id, 'datr_mandantID', true)); foreach ($locations as $id => $locationName) { if (isset($_POST['location_' . $id])) { EventDatabaseManager::addLocationToUser($user_id, $id); } else { EventDatabaseManager::removeLocationFromUser($user_id, $id); } } update_user_meta($user_id, 'datr_gender', $_POST['datr_gender']); update_user_meta($user_id, 'datr_title', $_POST['datr_title']); update_user_meta($user_id, 'datr_mandantID', $_POST['datr_mandantID']); update_user_meta($user_id, 'datr_department', $_POST['datr_department']); }