jkirk001 Posted September 27, 2015 Report Posted September 27, 2015 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. Quote
0 jkirk001 Posted September 28, 2015 Author Report Posted September 28, 2015 Outstanding heroes!!! After changing code to Naja7host's latest code and removing $this->client = $this->Clients->get($this->Session->read("blesta_client_id") ; Flawless victory! Thanks again to everyone's help. Much appreciated. Blesta Addons and Michael 2 Quote
0 Michael Posted September 27, 2015 Report Posted September 27, 2015 Not much you can do to work around that, unless you make a custom nav only available for logged in users. Quote
0 jkirk001 Posted September 27, 2015 Author Report Posted September 27, 2015 Ah, was afraid that'd be the case. Oh well, at least that's on less thing for me to have to worry about. Quote
0 Michael Posted September 27, 2015 Report Posted September 27, 2015 Ah, was afraid that'd be the case. Oh well, at least that's on less thing for me to have to worry about. There might be a if statement for logged in but the guys would know more about that. Quote
0 Blesta Addons Posted September 27, 2015 Report Posted September 27, 2015 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 . Michael 1 Quote
0 jkirk001 Posted September 27, 2015 Author Report Posted September 27, 2015 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. Quote
0 Michael Posted September 28, 2015 Report Posted September 28, 2015 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 } Quote
0 Blesta Addons Posted September 28, 2015 Report Posted September 28, 2015 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) Michael and jkirk001 2 Quote
0 jkirk001 Posted September 28, 2015 Author Report Posted September 28, 2015 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! Quote
0 Tyson Posted September 28, 2015 Report Posted September 28, 2015 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). jkirk001 and Michael 2 Quote
0 jkirk001 Posted September 28, 2015 Author Report Posted September 28, 2015 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. Quote
0 Tyson Posted September 28, 2015 Report Posted September 28, 2015 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"); Michael and jkirk001 2 Quote
0 jkirk001 Posted September 28, 2015 Author Report Posted September 28, 2015 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. Quote
0 Blesta Addons Posted September 28, 2015 Report Posted September 28, 2015 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); } activa, jkirk001 and Michael 3 Quote
Question
jkirk001
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.
14 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.