get_results("SELECT * FROM {$wpdb->prefix}ace_register_fields ORDER BY sortby ASC"); $success = ''; $errors = []; if ($_SERVER['REQUEST_METHOD'] === 'POST') { // PROFILE IMAGE UPLOAD if (!empty($_POST['update_profile']) && check_admin_referer('ace_update_profile')) { if (!empty($_FILES['profile_img']['name'])) { $file = $_FILES['profile_img']; $allowed_types = ['image/jpeg', 'image/gif', 'image/png']; $upload_dir = wp_upload_dir(); $target_file = $upload_dir['path'] . '/' . basename($file['name']); if (!in_array($file['type'], $allowed_types)) { $errors[] = "Invalid file type. Allowed: JPG, GIF, PNG."; } elseif ($file['size'] > 800 * 1024) { $errors[] = "File too large. Max size: 800KB."; } elseif (!move_uploaded_file($file['tmp_name'], $target_file)) { $errors[] = "Failed to upload image."; } else { $uploaded_url = $upload_dir['url'] . '/' . basename($file['name']); update_user_meta($current_user->ID, 'custom_avatar', esc_url($uploaded_url)); $success .= "
Profile image updated successfully.
"; } } // Save custom fields $sanitized = Ace_User_Management_Function::sanitize($_POST); $meta_fields = array_combine( array_map(fn($k) => $k . '_', array_keys($sanitized)), $sanitized ); if (update_user_meta($current_user->ID, 'user_extrafields', $meta_fields)) { foreach ($sanitized as $key => $val) { update_user_meta($current_user->ID, $key, sanitize_text_field($val)); } $success .= "
Profile updated successfully.
"; } } // PASSWORD CHANGE if (!empty($_POST['change_password']) && check_admin_referer('ace_change_password')) { $pass1 = sanitize_text_field($_POST['password']); $pass2 = sanitize_text_field($_POST['confirm_password']); if ($pass1 && $pass1 === $pass2) { wp_set_password($pass1, $current_user->ID); wp_logout(); wp_redirect(wp_login_url()); exit; } else { $errors[] = "Passwords do not match or are empty."; } } // ACCOUNT INFO if (!empty($_POST['account_info']) && check_admin_referer('ace_account_info')) { $fields = [ 'billing_first_name', 'billing_last_name', 'billing_company', 'billing_city', 'billing_postcode', 'billing_zipcode', 'billing_country', 'billing_phone' ]; foreach ($fields as $field) { if (isset($_POST[$field])) { update_user_meta($current_user->ID, $field, sanitize_text_field($_POST[$field])); } } $success .= "
Billing information updated.
"; } } $user_extrafields_value = get_user_meta($current_user->ID, 'user_extrafields', true); $custom_avatar_url = get_user_meta($current_user->ID, 'custom_avatar', true); $profile_image = $custom_avatar_url ?: get_avatar_url($current_user->ID); $billing_fields_data = []; $billing_fields = [ 'billing_first_name', 'billing_last_name', 'billing_company', 'billing_city', 'billing_postcode', 'billing_zipcode', 'billing_country', 'billing_phone' ]; foreach ($billing_fields as $field) { $billing_fields_data[$field] = get_user_meta($current_user->ID, $field, true); } ?> "; endforeach; echo $success; ?>

Profile Image
Allowed JPG, GIF, or PNG. Max size 800K
Username
input_name); $field_value = esc_attr($user_extrafields_value[$field_name . '_'] ?? ''); ?>
input_type === 'text'): ?> input_type === 'textarea'): ?> input_type === 'dropdown'): ?>
'Billing Name', 'billing_last_name' => 'Billing Address', 'billing_company' => 'Company', 'billing_city' => 'City', 'billing_postcode' => 'State/Province', 'billing_zipcode' => 'Postal Code', 'billing_country' => 'Country', 'billing_phone' => 'Phone', ]; foreach ($billing_fields as $name => $label): ?>