Does this look right?

Hey Guys, I’m trying to firgure out what’s wrong. So I don’t want any pilots to access the retired pilots public profiles and here’s my code from profile.php.

if(!pilot::retired())
	{
		$this->set('message', 'Sorry! This Profile Is Not Available! ');
		$this->render('core_error.tpl');
		return;
	}

Can anyone help me to guide in the right direction and I’ll be happy to give you 1+ rep if you helped me. Thanks!

Assuming you’re working within the view function, place the following somewhere after $userinfo is defined.

if($userinfo->retired == 1)
               {
                       $this->set('message', 'Sorry! This Profile Is Not Available!');
                       $this->render('core_error.tpl');
                       return;
               }

Hopefully should work

1 Like

Nope didn’t work, Not sure why.

Anyone help me please!

Could you paste from the start of the index function?

1 Like

Is this your looking for. I ripped it off my porfile.php…

class Profile extends CodonModule
{

public function index()
{
	if(!Auth::LoggedIn())
	{
		$this->set('message', 'You must be logged in to access this feature!');
		$this->render('core_error.tpl');
		return;
	}

	/*
	 * This is from /profile/editprofile
	 */
	 if(isset($this->post->action))
	 {
		if($this->post->action == 'saveprofile')
		{
			$this->save_profile_post

My bad you want the view function… Assuming you haven’t modified it, and I haven’t modified it (taking this from EUG profile.php which I may have edited):

public function view($pilotid='')
{

	if(!is_numeric($pilotid))
	{
		preg_match('/^([A-Za-z]*)(\d*)/', $pilotid, $matches);
		$code = $matches[1];
		$pilotid = intval($matches[2]) - Config::Get('PILOTID_OFFSET');
	}

	$userinfo = PilotData::getPilotData($pilotid);

	if($userinfo->retired == '1'){
		$this->set('message', 'Sorry, this profile is not available.');
		$this->render('core_error.tpl');
		return;
	}

	$this->title = 'Profile of '.$userinfo->firstname.' '.$userinfo->lastname;

	$this->set('userinfo', $userinfo);
	$this->set('allfields', PilotData::GetFieldData($pilotid, false));
	$this->set('pireps', PIREPData::GetAllReportsForPilot($pilotid));
	$this->set('pilotcode', PilotData::GetPilotCode($userinfo->code, $userinfo->pilotid));
	$this->set('allawards', AwardsData::GetPilotAwards($userinfo->pilotid));

	$this->render('pilot_public_profile.tpl');
	$this->render('pireps_viewall.tpl');
}
1 Like

Yep it does work now. Thanks for your help Tom,

I had a mistake in the coding, so i now understand.

Thanks!