You cannot put an
if
block inside an array declaration. You need to extract that part:
if ($status == 'Peserta') {
$role_id = 6;
} else if ($status == 'Pengurus') {
$role_id = 5;
} else {
$role_id = 2;
}
$data = [
'name' => htmlspecialchars($this->input->post('name', true)),
'email' => htmlspecialchars($email),
'password' => password_hash($this->input->post('password1'), PASSWORD_DEFAULT),
'role_id' => $role_id,
'is_active' => 0,
'date_created' => time()
];