We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2139
    • 3 Posts
    I created a snippet with the following code but I dont get the email address.

    <?php
    $userID = $modx->getLoginUserID();
    $table = $modx->getFullTableName("web_user_attributes");
    $userEmail = $modx->db->select("email" ,$table, "id = $userID", "", "");
    echo $userID;
    echo "
    ";
    echo $userEmail;
    ?>


    This returns the following:

    1
    Resource id #14


    Where am i going wrong?

    Thanks
    davehaslam@davehaslam.co.uk
      • 4310
      • 2,310 Posts
      <?php
      print_r($_SESSION[’webEmail’]);
      ?>
        • 2139
        • 3 Posts
        Thanks

          • 4041
          • 788 Posts
          You can access the following variables (+ a few others) of a logged in webuser from the session without any DB queries.

          $_SESSION[webShortname]
          $_SESSION[webFullname]
          $_SESSION[webEmail]
          $_SESSION[webValidated]
          $_SESSION[webInternalKey]
          $_SESSION[webValid]
          $_SESSION[webUser]
          $_SESSION[webFailedlogins]
          $_SESSION[webLastlogin]
          $_SESSION[webnrlogins]
          $_SESSION[webUserGroupNames]
          $_SESSION[webDocgroups]


          you can use the following snippet to show all session variables, create a new snippet and call it at the bottom of a content page.
          <?php
          // ShowSession    [!ShowSession!]
          $output ="";
          $output .= print_r($_SESSION);
          return $output;
          ?>
            xforum
            http://frsbuilders.net (under construction) forum for evolution
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            This may be of interest... http://sottwell.com/article-sessions.html
              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