We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 50267
    • 2 Posts
    Hi, I'm newbie in Modx and I'm working in a website developed on Revolution 2.1.3-pl.

    The site has some non-modx tables designed for a particular module that allows to visitors to register in a website section for ask for tips/questions.

    Now I need to display the user email if it logged, my question is, how can I make this and show it on the header of the site (a sql query perhaps?). If it not logged (or is not registered) display the message "Your not logged".

    I have the following code tested on a snippet but that's just the beginning:

    <?php
    $link = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    
    $cookie_name = "user";
    $cookie_value = $_POST["mail"];
    setcookie($cookie_name, $cookie_value,  time() + (60 * 30), "/"); // 5 min
    
    //If user is on the questions section
    if(strpos($link, '/tips-help/') !== false){
       echo "Welcome";
       echo "Your Email is: " .$_POST["mail"];
    
    }
    //If user is out of the questions section
    else{
       echo "You are out";
    }
    


    Any help would really appreaciated,
    Regards.
      • 4172
      • 5,888 Posts
      is there a reason for not using the MODX - user-system?
      I think, this would make things much easier.

      To check, if a user is in a specific section, you could create a TV 'section'
      with @INHERIT as default value (this does inherit the value to all children)
      and set the value of the top-parent to 'tips-help'

      then in your snippet:

      if ($modx->resource->getTVValue('section') == 'tips-help'){
          $output = $modx->getChunk($yesChunk);
      } else {
          $output = $modx->getChunk($noChunk);
      }
      
      return $output;



        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 50267
        • 2 Posts
        Thanks for your response.

        This particular module in the site was designed independently and works with 3 extra tables (for users, questions and responses) as I understand who developed it wanted to keep separted these external users of the managers or admins (we also have several editors) in the site.

        That's the reason that we have and use both, modx_users and q_users tables, but I'm agree with you, working just with modx_users would make things easier.

        I'll try your suggestion,
        Regards
        • That is what user groups are for. Only users belonging to groups that have permission to access the "mgr" context are manager or admin users. Other groups are given access to the "web" context.
            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
            • 3749
            • 24,544 Posts
            By all means make them all MODX users in the modx_user table if possible. It will give you access to lots of solid extras that you won't be able to use otherwise and finer control over which pages they can, and can't, see.
              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