Hi, I’m a new MODX user and I’m trying to do the following:
I’ve got a page that should only be visible to logged in Manager Users on the ’frontend’ of the website. I’ve tried all sorts of things, but the problem seems to be that I can only set accessibility of pages to Web User groups. So if I log in as a Manager User I can still not see a certain page that is only visible to a group of Web Users on the frontend of the page (I’m using the ManagerLogin snippet and the QuickEdit module to edit pages on frontend).
Does anyone know if the thing I want is possible? I also tried the Web2Manager plugin but from what I can see this only creates a web user that has the same username and password as a manager user. But if I login as a manager I still don’t see the specific page that is assigned to the web user with the same login credentials.
So in short I would like to do the following:
- login on frontend as manager user with ManagerLogin snippet
- be able to edit pages with quickedit on frontend
- be able to see manager-only pages on frontend
Thanks in advance for any help!!
BTW, I’m using ModX 0.9.6.3
Michelle
Hi Michelle, Welcome to Modx.
The best damn cms on the planet and as far as i know the galaxy
try using $modx->getLoginUserType(). it will return either web or manager. if you want to see how the function works check out line 2015 in manager/includes/document.parser.class.inc.php
For this I recommend creating a new template specifically for the pages you want to protect with this snippet.
Take the code below, create a new snippet (name it whatever you want, I used Manager_only but it doesn’t matter).
Modify the $redirect_url to match whatever page you want to redirect non logged users to.
Add the snippet call to the top of the template (use uncached: [!Manager_only!] )
<?php
/* Manager_only
checks to see if a manager session is found, if not
redirect them to $redirect_url
*/
$redirect_url ="http://yoursite.com";
if(!isset($_SESSION['mgrInternalKey'])){
header("Location: $redirect_url");
}
?>
Wow, thanks so much! Modx is indeed a fantastic CMS, and with a friendly community!
Breezer, your suggestion works perfectly! Is there also a way to make the menu-item only appear in the menu when logged in?
-
☆ A M B ☆
- 24,524 Posts