<![CDATA[ [Snippet] ManagersOnly - My Forums]]> https://forums.modx.com/thread/?thread=35836 <![CDATA[Re: [Snippet] ManagersOnly]]> https://forums.modx.com/thread/35836/snippet-managersonly#dis-post-541543
<?php
if($modx->user->isAuthenticated('mgr')) {
    return $html;
} else {
    return false;
}


Snippet using:
[[!ManagersOnly? &html=`<button>My hidden button</button>`]]

]]>
pyotruk May 15, 2016, 08:34 AM https://forums.modx.com/thread/35836/snippet-managersonly#dis-post-541543
<![CDATA[Re: [Snippet] ManagersOnly]]> https://forums.modx.com/thread/35836/snippet-managersonly#dis-post-491853
Is the snippet that Bob posted above the actual snippet code, or it's just a part? I noticed there's no attachment in this thread.]]>
diatomin Mar 05, 2014, 10:20 AM https://forums.modx.com/thread/35836/snippet-managersonly#dis-post-491853
<![CDATA[Re: [Snippet] ManagersOnly]]> https://forums.modx.com/thread/35836/snippet-managersonly#dis-post-200240
Cheers,

Jay]]>
smashingred Jan 14, 2009, 05:37 AM https://forums.modx.com/thread/35836/snippet-managersonly#dis-post-200240
<![CDATA[Re: [Snippet] ManagersOnly]]> https://forums.modx.com/thread/35836/snippet-managersonly#dis-post-200239
$outputchunk = $modx->getChunk($chunk);


Should be the first line inside the if statement. Otherwise, you’re fetching the chunk every time the page is accessed whether there’s a manager user on or not. IOW:

if($_SESSION['mgrValidated']){

        $outputchunk = $modx->getChunk($chunk);

        //Check to see if there is a chunk to output
            if ($outputchunk){
                return $outputchunk;
            }
            // If Debug is turned on, output error. (kind of overkill for a small snippet like this--did it for practice.)
            elseif ($debug == '1'){
                return 'The chunkname '.$chunk.' doesn\'t appear to be valid or exist.';
            }
    }   else {
        //End the script
        return false;
    }
]]>
BobRay Jan 13, 2009, 10:00 PM https://forums.modx.com/thread/35836/snippet-managersonly#dis-post-200239
<![CDATA[Re: [Snippet] ManagersOnly]]> https://forums.modx.com/thread/35836/snippet-managersonly#dis-post-200238

Thanks for sharing.]]>
zaigham Jan 07, 2008, 04:46 AM https://forums.modx.com/thread/35836/snippet-managersonly#dis-post-200238
<![CDATA[Re: [Snippet] ManagersOnly]]> https://forums.modx.com/thread/35836/snippet-managersonly#dis-post-200237 Quote from: bunk58 at Jan 05, 2008, 09:04 PM

What a clever little snippet!
Thanks. I am learning more and more PHP and trying to extend some other snippets. This one enabled me to see how to get a template from a chunk. I want to add that to FDM so that it can have a default field set.

Quote from: bunk58 at Jan 05, 2008, 09:04 PM

Can I just point out you don’t need to add the chunk to the page, only to the snippet call.

Thanks

David
Yes. I should mention that in the instructions. The chunk call should not be in the page call or it will be accessible to the public. It should only be in the snippet call.

Quote from: dev_cw at Jan 05, 2008, 11:04 PM

This is nice. Thanks.

Thanks also.]]>
smashingred Jan 05, 2008, 05:08 PM https://forums.modx.com/thread/35836/snippet-managersonly#dis-post-200237
<![CDATA[Re: [Snippet] ManagersOnly]]> https://forums.modx.com/thread/35836/snippet-managersonly#dis-post-200236 dev_cw Jan 05, 2008, 05:04 PM https://forums.modx.com/thread/35836/snippet-managersonly#dis-post-200236 <![CDATA[Re: [Snippet] ManagersOnly]]> https://forums.modx.com/thread/35836/snippet-managersonly#dis-post-200235 PHP Version 5.2.2 works fine.
Can I just point out you don’t need to add the chunk to the page, only to the snippet call.

Thanks

David]]>
bunk58 Jan 05, 2008, 03:04 PM https://forums.modx.com/thread/35836/snippet-managersonly#dis-post-200235
<![CDATA[ [Snippet] ManagersOnly]]> https://forums.modx.com/thread/35836/snippet-managersonly#dis-post-200234 ManagersOnly
A snippet based on Adam Crownoble’s LoginLogoutLink (8/3/2005) and MemberCheck by Ryan Thrash, Jason Coward (3/4/2007) .

Purpose
The purpose of ManagersOnly is to offer very light way to show/place content to/for Manager Users. This snippet doesn’t check group memberships, it will only check to see if the manager is logged in and return the contents of a chunk.

Note: If you would like a snippet that also checks group membership try Susan Otwell’s modified MemberCheck, ManagerCheck.

If logged in the manager user will see the chunk content where called. If not logged in no one else will see the links.

Usage

1. Place this text into a new snippet and name it ManagersOnly

2. Create a Chunk with the contents for managers only such as links or text.

3. Place snippet call into template or document. Where `chunkname` is the name of your chunk:

[!ManagersOnly? &chunk=`chunkname`!]

Important: Do not place the normal chunk call into your page or template as it will be publicly accessible.


Parameters
&chunk - Name of Chunk containing content to display [String] (REQUIRED)
&debug - Turns on Debugging to see what the problem is [0|1] (REQUIRED) Default = 0

Current Version: 0.1.1
Last Update: 06-01-2008 (Usage info update. No change to actual snippet code)

Note:

Looking for people to see how it works on their stacks. Especially PHP5. Any simple suggestions are welcomed.

]]>
smashingred Jan 05, 2008, 08:59 AM https://forums.modx.com/thread/35836/snippet-managersonly#dis-post-200234