We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24629
    • 370 Posts
    Hi all,
    i'm trying to make a members only kind of page, actually i don't know how to make CMP's so i use the web context for that.
    i have a resource group (editorfiles) and a usergroup (editors) that has access to the resourcegroup.
    Anyway i'm counting on the premises that once a 'editor' is loggedin in the manager he also has access to a page belongin in that resource group, in the web context. i have
    Is that true? or does my member also need to login on the web context separately?

    the editorsgroup has cotext acces to mgr and web with a policy of administrator. and resourcegroup acces with a policy of 'resource'.
    but when i'm logged in in the manager i can't see the front-end memberpage.
    ACL's are realy tough.

    RDG
      • 3749
      • 24,544 Posts
      No, being logged into the Manager does not mean you're logged in to any other context. That's why you can't see the front-end web page unless you're also logged in in the front-end context.

      You should be able to use a plugin attached to OnManagerLogin to automatically log the person into the front-end context if you need to.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 24629
        • 370 Posts
        Hoi Bobray,
        Thanks i understand. can you point me towards a script that does the login? the addon 'Login' is a bit to complex for me to unraffle.

        LHM
          • 3749
          • 24,544 Posts
          OK, this is off the top of my head, but I think it may work. Put this code in a plugin and attach the plugin to the OnManagerLogin event:

          $user->addSessionContext('web');
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 24629
            • 370 Posts
            Hi,
            I tried it but it doesn't work. i think there must also be some verification to see if the user is allowed to login.

            RDG
              • 3749
              • 24,544 Posts
              No, there are no permission checks at that low a level.

              See if this works:


              $modx->getUser();
              $modx->user->addSessionContext('web');
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 24629
                • 370 Posts
                Hoi BobRay,

                no that doesn't seem to work either. Is there a way to read to console or PHP echo all the user data (authorisation, context etc)?
                so i can see exactly what changes in the user settings after i login on the web context.

                RDG
                  • 3749
                  • 24,544 Posts
                  You usually can't echo anything in a plugin, but you can write the data to a chunk (create a chunk called 'Debug').


                  if (!function_exists("my_debug") && $scriptProperties['debug']) {
                      function my_debug($message, $clear = false)
                      {
                          global $modx;
                  
                          $chunk = $modx->getObject('modChunk', array('name' => 'Debug'));
                          if (!$chunk) {
                              $chunk = $modx->newObject('modChunk', array('name' => 'Debug'));
                              $chunk->setContent('');
                              $chunk->save();
                              $chunk = $modx->getObject('modChunk', array('name' => 'Debug'));
                          } else {
                              if ($clear) {
                                  $content = '';
                              } else {
                                  $content = $chunk->getContent();
                              }
                          }
                          $content .= $message . "\n";
                          $chunk->setContent($content);
                          $chunk->save();
                      }
                  }
                  
                  $msg = print_r($scriptProperties, true);
                  
                  my_debug($msg, true);
                  
                  $userFields = $user->toArray();
                  
                  $msg = "\n *********************** \n" . print_r($userFields, true);
                  my_debug($msg);


                  BTW, it occurs to me that the first thing to check is whether OnManagerLogin is firing at all. The plugin code may not be executing, which would explain why it doesn't work. wink
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 24629
                    • 370 Posts
                    I think you're right. it looks like the onmanagerlogin doesn't fire. i put a xpdo->log in there and can't find a trace of it
                    $eventName = $modx->event->name;
                    switch($eventName) {
                        case 'OnManagerLogin ':
                    		$modx->log(xPDO::LOG_LEVEL_ERROR,'-OnManagerLogin in weblogin plugin');
                    		$modx->getUser();
                           	$modx->user->addSessionContext('web');
                       	break;
                    
                    }

                    And i did logout and in again on the manager. is there another way to check if the event fires at all?
                      • 24629
                      • 370 Posts
                      just spottd the space in the case statement. the event fires allright. but no login yet