prepare("UPDATE writer_applications SET status = 'approved' WHERE id = ?");
$stmt->execute([$application_id]);
// Update user role
$stmt = $pdo->prepare("UPDATE users SET role = 'writer' WHERE id = ?");
$stmt->execute([$user_id]);
$message = '
Application approved. User is now a writer.
';
} elseif (isset($_POST['reject'])) {
// Update application status
$stmt = $pdo->prepare("UPDATE writer_applications SET status = 'rejected' WHERE id = ?");
$stmt->execute([$application_id]);
$message = 'Application rejected.
';
}
}
// Fetch pending applications
$stmt = $pdo->prepare("SELECT wa.*, u.username FROM writer_applications wa JOIN users u ON wa.user_id = u.id WHERE wa.status = 'pending'");
$stmt->execute();
$applications = $stmt->fetchAll();
?>
Admin Panel - Writer Applications
To test this page, you need to manually set a user's role to 'admin' in your database. For example:
UPDATE users SET role = 'admin' WHERE id = 1;
| Username |
Bio |
Action |
| No pending applications. |
|
|
|