Jump to content
  • 0

How To Make Order System Available To Logged In Clients Only?


jkirk001

Question

14 answers to this question

Recommended Posts

  • 0

How (if possible) would I go about making the Order System available only to logged in clients?  But, I'd still like Knowledge Base, My Account, and Support to be available to public.

 

 

you should edit the order conroller and add

$this->requireLogin();

now only the logged in client will be able to view the order form  content .

Link to comment
Share on other sites

  • 0

Thanks Licensecart & naja7host! With 

$this->requireLogin();

Order System is still visible when not logged in, but leads to blank page. When logged in, it is both visible and functions properly. I suppose I could drop in a message "User must be logged in to place order" (or something like that).  If I'm not mistaken, I think I saw a post regarding such a message.

 

I appreciate you two having taken the time to help me.

Link to comment
Share on other sites

  • 0

Thanks Licensecart & naja7host! With 

$this->requireLogin();

Order System is still visible when not logged in, but leads to blank page. When logged in, it is both visible and functions properly. I suppose I could drop in a message "User must be logged in to place order" (or something like that).  If I'm not mistaken, I think I saw a post regarding such a message.

 

I appreciate you two having taken the time to help me.

 

Try this mate at the top:

 

$loggedin = $this->requireLogin();

 

if( !$loggedin ){

 

echo "sorry you need to be logged in to place an order";

 

}else{

 

Then at the bottom of the page put a  }

Link to comment
Share on other sites

  • 0

normally it should redirect unlogged client to login page .

 

try this one

$this->requireLogin($this->client_uri);

or set a redirect or set a input error message

 

redirect :

$this->redirect($this->client_uri);

set error message :

$this->setMessage("sorry you need to be logged in to place an order", $error, true, null, false)
Link to comment
Share on other sites

  • 0

Hello again,

 

Sorry guys, I've tried the two solutions you two have provided. Unfortunately, if I place the "requirelogin" followed by the "if" statement below the opening php tag, it give an "Ohnoes". If placed anywhere else, leads to blank screen. Only one situation with redirect was I able to get close to solution However, after login, "Return to Portal" > "Order" redirects to "My Account". But have not been able to replicate since. I've submitted ticket to see what the devs at Blesta can come up with. I am certain this can be resolved. Will post best solution when issue is resolve.

 

Thanks again!

Link to comment
Share on other sites

  • 0

As naja7host mentioned, you can redirect to the client URI for clients not logged in with

$this->requireLogin($this->client_uri);

If you want to show a message, you should set a flash message before that redirect

$this->flashMessage('notice', "You must be logged in to use the order system.", null, false);
$this->requireLogin($this->client_uri);

If you don't want the "Order" box to appear on the portal page, you can update the portal to remove the HTML that displays it from within Blesta under [settings] -> [Plugins] -> Portal (Manage link).

Link to comment
Share on other sites

  • 0

Okay, almost there.  I had a simple typo.  Now, with

<?php
/**
 * Order System Parent Controller
 * 
 * @package blesta
 * @subpackage blesta.plugins.order
 * @copyright Copyright (c) 2010, Phillips Data, Inc.
 * @license http://www.blesta.com/license/'>http://www.blesta.com/license/ The Blesta License Agreement
 * @link http://www.blesta.com/ Blesta
 */

class OrderController extends AppController {
	public function preAction() { 
		$this->structure->setDefaultView(APPDIR);
		
		parent::preAction();
		$this->flashMessage('notice', "You must be logged in to use the order system.", null, false);
                $this->requireLogin($this->client_uri);               

		// Auto load language for the controller			
		Language::loadLang(array(Loader::fromCamelCase(get_class($this))), null, dirname(__FILE__) . DS . "language" . DS);
		
		// Override default view directory		
		$this->view->view = "default";
		$this->orig_structure_view = $this->structure->view;
		$this->structure->view = "default";		
	}
}

require_once dirname(__FILE__) . DS . "order_form_controller.php";
?>

it displays the message above Order Form when: logged in > Return to Portal > Order. When logged out, redirects to login but no message.  Sorry to be such a pest.  You guys are great! I appreciate your time.

Link to comment
Share on other sites

  • 0

it displays the message above Order Form when: logged in > Return to Portal > Order. When logged out, redirects to login but no message.  Sorry to be such a pest.  You guys are great! I appreciate your time.

 

I think this is because you're being redirected twice. Try changing the redirect URI to the login page itself then.

$this->requireLogin($this->client_uri . "login");   
Link to comment
Share on other sites

  • 0

Thanks Tyler!

 

It properly redirects user to login with message. And allows only logged in clients to place orders. So,that works with one minor issue: the message still displays above the order form when logged in. If unable to resolve, not a deal breaker.

 

yes, bacause you should add a condition for the message  , the message will appear for logged in when they load new page .

 

so , i can suggest this new code

// Set the client info
$this->client = $this->Clients->get($this->Session->read("blesta_client_id") ;
  if (!$this->client) {
      $this->flashMessage('notice', "You must be logged in to use the order system.", null, false);
      $this->requireLogin($this->client_uri);
  }
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...