We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25803 ☆ A M B ☆
    • 721 Posts
    Hello,

    In this thread, Breezer was kind enough to write a modification where we could designate a Home Page ID in the Manager and anyone logging in would be directed to that designated page regardless of the liHomeId setting.

    In my case, users who initially register are directed to a Pending Users page until they approved by an administrator so the liHomeId is set to that page. When they are approved, the Home Page ID is set in the Manager and they go to their custom page.

    My question is, even if you’re not using the above modification and are using the standard &liHomeId=`4,12,17,22` which of course, also directs users to the appropriate page on login, how do you redirect them there with a standard menu item (i.e. a standard text link for example) if the user navigates away from that page? In my case, I’ve created a custom submenu with a View/Edit Profile button and a logout button. I’d like to add a Your Page button to that as well as a Your Page link to the login page (as when they visit it while logged in, they’re simply told they are logged in).
      • 4041
      • 788 Posts
      This could be used as a stand alone snippet or taken apart and added to your existing code, I put a few simple examples of usage in it.. and yes some hard coded values which are just to show what its doing lol

      (removed snippet code, please see next post)
        xforum
        http://frsbuilders.net (under construction) forum for evolution
        • 4041
        • 788 Posts
        OK, after further research, it seems the web users login page ID is available as $_SESSION[webUsrConfigSet][login_home]

        You can grab it from any script, I removed the snippet I posted before, use this as it eliminates an unneeded database call smiley

        <?php
        /*    WebUser_Redirect
        
        */
        $output ="";
        if(isset($_SESSION['webValidated']) && isset($_SESSION['webShortname'])){
          $web_UserLoginHomeID =$_SESSION[webUsrConfigSet][login_home];
          if($web_UserLoginHomeID !=""){
        
                 // grab the current page id and compare to the users home id
                 // if it matches then print something, if not it creates the link or placeholder
                  $currentdoc = $modx->documentIdentifier;
                  if($currentdoc == $web_UserLoginHomeID){
                   // in this example it prints: Breezer's Home Page (Breezer would be the logged users name)
                    $output .=$_SESSION['webShortname']."'s Home Page";
                  }else{
                   // output a simple text link wherever this snippet is placed
                    $output .="<a href='[~".$web_UserLoginHomeID."~]' class='calrsslink'>Home Page</a>";
        
                   // or set a placeholder to use in the script later
                    $output .= $modx->setPlaceholder("WULoginHomeID", "$web_UserLoginHomeID");   // [+WULoginHomeID+]
        
                   // example of placeholder usage
                    $output .="<a href='[~[+WULoginHomeID+]~]' class='calrsslink'>Home Page</a>";
                  }
           }
        }
        
        return $output;
        ?>
          xforum
          http://frsbuilders.net (under construction) forum for evolution
          • 25803 ☆ A M B ☆
          • 721 Posts
          Thank you very much. This is much appreciated. I will give it a try tomorrow.
          I’m beginning to think WebLoginPE and snippets like this one and GreetByName would make a nice package.
            • 25803 ☆ A M B ☆
            • 721 Posts
            Worked great. Thanks again. Using:

            $output .="<li><a href='[~".$web_UserLoginHomeID."~]' class='calrsslink'>Your Page</a></li>"


            Not there when it’s not supposed to be, there when it is. Wonderful.

            Ultimately, it would be ideal, I’d imagine, for many users of WebLoginPE, if all users could optionally be directed to a single page and then the content presented (probably in chunks) was triggered by their user name. However, even creating a page for each user (for low volume) is pretty user friendly for the client.

            In my case I’m linking to customized surveys using phpQuestionnaire (the id of the questionnaire being triggered by a TV). I’m not sure how to have a list of user names that can be bound to a particular TV, such as when it’s user Y the id of the survey is 10, when x the survey id is 11, etc. A very generic way of doing this, user name to a set of TVs if necessary would be very powerful. I’d imagine you’d have to get an array of user names from the manager (and only of course, be able to assign content in the manager) and then somehow bind them to various template variables.
              • 20413
              • 2,877 Posts
              I am using: <a href="[~[+country+]~]">user</a> as a solution!!  grin

              1. Using the awesome ShowMember Snippet
              2. Took away country choice from FormSignup.
              3. Then I assign user to countries in manager that match the id of their homepage ids.


              ------------edit-----------------------
              Well I dont use WebLoginPE at all but may have some relevance anyway....
              and I read the question all wrong too... : Þ
                @hawproductions | http://mrhaw.com/

                Infograph: MODX Advanced Install in 7 steps:
                http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                • 21700
                • 42 Posts
                Thank you Breezer, great tool! Works like a charm!