We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4041
    • 788 Posts
    This is untested but I think it will work. It will:
    1. check for user logged in, if a login home is set it outputs a link to the users current login home page
    2. new users get the table updated and outputs a link to their page

    <?php
    /*   WebUser_SetLoginHomeID.snippet.php
         last edit:  6/28/08  12:20 am est
         
         usage: create a new snippet and name it whatever you want
                call it in a document, ideally the one the user is
                redirected to after registration. This snippet will
                check the users data for a current login_home setting,
                if none is present, it populates the fields according
                to the snippet call. It then outputs a link to the users
                Login Home page.
                
                newLHID --> ID of the document you want to set as home
                
                [!SetLoginHomeID? newLHID=`14`!]
    */
    //###  SETTINGS  #################################################//
    // set a default fallback page ID
    $default_LoginHomeID =1;
    // link text for new members
    $new_LoginHomeID_linktext ="Visit your Home Page";
    // link text for current members
    $cur_LoginHomeID_linktext ="Home Page";
    // your home page link styling
    $linkclass ="class='calrsslink'";
    
    //### END SETTINGS ###############################################//
    $output ="";
    
    if(isset($_SESSION['webValidated'])){
       $new_LoginHomeID = isset($newLHID) ? $newLHID : $default_LoginHomeID;
       $cur_LoginHomeID =$_SESSION[webUsrConfigSet][login_home];
          if($cur_LoginHomeID ==""){
            $table_name = $modx->getFullTableName( 'web_user_settings' );
            $fields = array(
                            'webuser'             => $_SESSION['webInternalKey'],
                            'setting_name'        =>  'login_home',
                            'setting_value'       => $new_LoginHomeID,
                            );
            $modx->db->insert( $fields, $table_name);
            $output .="<a href='[~".$new_LoginHomeID."~]' ".$linkclass.">".$new_LoginHomeID_linktext."</a>";
          }else{
          $output .="<a href='[~".$cur_LoginHomeID."~]' ".$linkclass.">".$cur_LoginHomeID_linktext."</a>";
          }
    }
    return $output;
    ?>

      xforum
      http://frsbuilders.net (under construction) forum for evolution