We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11413
    • 203 Posts
    Hi,

    I want to use external PHP files to build my module. I know I just have to use "require(’filename.php’);" but In that file... is there an easy way of keeping it from executing if it’s called from outside the manager?

    something like :

    if (!$Is_in_manager) {
    die('you can,t do that!');
    }


    ???

    Also, how can I detect the user role and/or group? I want to show some sections depending on who is using it smiley

    bye and thanks in advance!!

    Blaise
      Blaise Bernier

      www.medialdesign.com - Solutions for small business, hosting, design and more!
    • Take a look at other Manager files, they all have a line at the beginning checking for just these things:

      if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the MODx Content Manager instead of accessing this file directly.");
      if(!$modx->hasPermission('save_snippet') && $_REQUEST['a']==24) {
      	$e->setError(3);
      	$e->dumpError();	
      }
      


      You can access the user values directly from the $_SESSION if you want.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 11413
        • 203 Posts
        Thanks! I think a short article should be written in the Doc about that... it could be usefull at least to have this copy/paste code smiley
          Blaise Bernier

          www.medialdesign.com - Solutions for small business, hosting, design and more!