Welcome Guest, Not a member yet? Register   Sign In
Looking for a better solution...
#1

[eluser]ivains[/eluser]
Hi Everyone,

I am looking for a better way of doing this code to work on a global scale. When the member logs in if his/her profile required fields are not complete they will be redirected to the profile page automatically regardless of what link is click on.

I have this working but just on the main page and would like it to work globally.

Controller:
Code:
function index()
{
$id = getUserProperty('id');

$query =  $this->db->query("SELECT * FROM user_profile WHERE id = $id ");

foreach($query->result() as $row){

if($row->id == ''){
$data['profiles']= $this->Profile_model->getProfile();
$this->load->view('FreakAuth_light/myaccount/profile', $data);
}
elseif($row->user_name == ''){
$data['profiles']= $this->Profile_model->getProfile();
$this->load->view('FreakAuth_light/myaccount/profile', $data);
}
elseif($row->fname == '' || $row->fname == 'NULL'){
$data['profiles']= $this->Profile_model->getProfile();
$this->load->view('FreakAuth_light/myaccount/profile', $data);
}
elseif($row->lname == '' || $row->lname == 'NULL'){
$data['profiles']= $this->Profile_model->getProfile();
$this->load->view('FreakAuth_light/myaccount/profile', $data);
}
elseif($row->dob == ''){
$data['profiles']= $this->Profile_model->getProfile();
$this->load->view('FreakAuth_light/myaccount/profile', $data);
}
elseif($row->pob == ''){
$data['profiles']= $this->Profile_model->getProfile();
$this->load->view('FreakAuth_light/myaccount/profile', $data);
}
elseif($row->nationality == ''){
$data['profiles']= $this->Profile_model->getProfile();
$this->load->view('FreakAuth_light/myaccount/profile', $data);
}
elseif($row->gender == ''){
$data['profiles']= $this->Profile_model->getProfile();
$this->load->view('FreakAuth_light/myaccount/profile', $data);
}
elseif($row->status == ''){
$data['profiles']= $this->Profile_model->getProfile();
$this->load->view('FreakAuth_light/myaccount/profile', $data);
}
elseif($row->addr1 == ''){
$data['profiles']= $this->Profile_model->getProfile();
$this->load->view('FreakAuth_light/myaccount/profile', $data);
}
elseif($row->city == ''){
$data['profiles']= $this->Profile_model->getProfile();
$this->load->view('FreakAuth_light/myaccount/profile', $data);
}
elseif($row->state == ''){
$data['profiles']= $this->Profile_model->getProfile();
$this->load->view('FreakAuth_light/myaccount/profile', $data);
}
elseif($row->postal == ''){
$data['profiles']= $this->Profile_model->getProfile();
$this->load->view('FreakAuth_light/myaccount/profile', $data);
}
elseif($row->hometel == ''){
$data['profiles']= $this->Profile_model->getProfile();
$this->load->view('FreakAuth_light/myaccount/profile', $data);
}
elseif($row->ben_fname == ''){
$data['profiles']= $this->Profile_model->getProfile();
$this->load->view('FreakAuth_light/myaccount/profile', $data);
}
elseif($row->ben_lname == ''){
$data['profiles']= $this->Profile_model->getProfile();
$this->load->view('FreakAuth_light/myaccount/profile', $data);
}
elseif($row->ben_phone == ''){
$data['profiles']= $this->Profile_model->getProfile();
$this->load->view('FreakAuth_light/myaccount/profile', $data);
}
elseif($row->ben_relationship == ''){
$data['profiles']= $this->Profile_model->getProfile();
$this->load->view('FreakAuth_light/myaccount/profile', $data);
}
else{
$data['profiles']= $this->Profile_model->getProfile();
$data['announcements']= $this->Announcements_model->getAllAnnouncements();
$this->load->view('FreakAuth_light/myaccount/myaccount', $data);
}
}
}

There are more fields to this table, however; these are the required ones.

Basically I want this performed globally. As of now it only works with the first page and if I click the other links they are taken away from the profile page.

Any suggestions/recommendations would be gratefully appreciated. This is my first project with CI. Wink

Thanks
Ivan
#2

[eluser]Colin Williams[/eluser]
Code:
$req_fields = array($row->id, $row->user_name, $row->fname, /* And so on */);
if (in_array('', $req_fields))
{
   $this->load->view('FreakAuth_light/myaccount/profile', $data)
}
else
{
   $data['profiles']= $this->Profile_model->getProfile();
   $data['announcements']= $this->Announcements_model->getAllAnnouncements();
   $this->load->view('FreakAuth_light/myaccount/myaccount', $data);
}
#3

[eluser]ivains[/eluser]
Thank you so much Colin! Especially for the quick reply. Big Grin




Theme © iAndrew 2016 - Forum software by © MyBB