get_results("SELECT * FROM {$wpdb->prefix}ace_register_fields ORDER BY sortby ASC"); $success = ''; $errors = []; require_once plugin_dir_path( __FILE__ ). 'countries.php'; 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 .= "