We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7455
    • 2,204 Posts
    mm thats strange. was the timestamp placed or was this also 0?
    maybe we need to change the code a bit.

      follow me on twitter: @dimmy01
      • 7455
      • 2,204 Posts
      ok changed the code again the plugin code that is.

      it should write the wuid now
        follow me on twitter: @dimmy01
        • 25551 ☆ A M B ☆
        • 1,231 Posts
        Ok here’s my auto page create plugin code

        if($mode=="new"){   
        	$table_name = $modx->getFullTableName( 'site_content' );
        	$fields = array(
                                'type'	=>  'document',
        			'contentType'	=> 'text/html',
        			'content'	=> '<div class="contentcontainer">[!WebLoginPE?!]</div>
        <div class="contentcontainer" style="text-align:left; background-color:#444; padding:40px 0 40px 20%">       
        [!Ditto? &tpl=`clientTPL`  &summarize=`15` &total=`9` &sortBy=`createdon` &sortDir=`ASC` &descendentDepth=`3` !]
        </div>
        ',
        			'pagetitle'	=> 'Your Design Pages',
        			'longtitle'	=> 'Main Design Pages Area',
        			'published'	=> '1', //is the page published?
        			'parent'	=> '58', //what is the parent of this new page?
        			'isfolder'	=> '1', // lets make this a folder
        			'template'	=> '21', //type template id here
        			'cacheable'	=> '0',
        			'createdby'	=> $wuid, 
        			'createdon'	=> time(),
        			'editedon'	=> time(),
        			'publishedon'	=> time(),
        			'hidemenu'	=> '1',
        			'privateweb' => '1',
        			
        			);
        	
        	$modx->db->insert( $fields, $table_name); // put the fields in the db (id wil be created incremental.)
        
        //Create  placeholder and put the id in a session to use for mail or whatever.
        $_SESSION['eigenpaginaid'] =  $modx->db->getInsertId();
        $modx->setPlaceholder('eigenpaginaid', $modx->db->getInsertId());
        $parent= $modx->db->getInsertId();
        
        //start of page creation, copy this part and past below for as many docs you want (I know we could use a loop but than the logtitle and page title are all the same)
        $fields = array(
                                'type'	=>  'document',
        			'contentType'	=> 'text/html',
        			'content'	=> '<div class="contentcontainer">[[Jot? &pagination=`10` &captcha=`1` &action=`form,comments` &subjectModerate=`0` &tplComments=`clienttickethistory`  &tplForm=`clientticket` ]]</div>',
        			'pagetitle'	=> 'Ticket System',
        			'longtitle'	=> 'Raise A Ticket',
        			'published'	=> '1', //is the page published?
        			'parent'	=> $parent, //here we go create a doc in the first doc
        			'isfolder'	=> '0',
        			'template'	=> '21', //type template id here
        			'cacheable'	=> '0',
        			'createdby'	=> $wuid,
        			'createdon'	=> time(),
        			'editedon'	=> time(),
        			'publishedon'	=> time(),
        			'hidemenu'	=> '1',
        			'privateweb' => '1',
        						);
        	
        	$modx->db->insert( $fields, $table_name); // put the fields in the db (id wil be created incremental.)
        //end of page creation
        
        
           return;
        }


        As you can see I have added some extra fields but everything is created corrently.

        Here is my redirect snippet

        <?php
        if($_SESSION["usertype"] == "manager") {$manager = "1";}
        $wuid  = "-".$modx->getLoginUserID();
        $owner =  $modx->documentObject['createdby'];
        if($wuid == $owner || $manager == "1"){
        return;
        }else{
        //$modx->sendRedirect($modx->makeUrl($modx->config['site_start']));
        return "userid=".$wuid." owner=".$owner;
        }
        ?>


        The redirect is not working... I can now access the pages made above even if I’m not signed in.
          Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
          AugmentBLU - MODX Partner

          BLUcart - MODX Revolution E-Commerce & Shopping Cart
          • 7455
          • 2,204 Posts
          if the createby is now -# than use the below script for the snippet that should work now

          <?php
          if($_SESSION["usertype"] == "manager") {$manager = "1";}
          $wuid  = "-".$modx->getLoginUserID();
          $owner =  $modx->documentObject['createdby'];
          if($wuid == $owner || $manager == "1"){
          return;
          }else{
          $modx->sendRedirect($modx->makeUrl($modx->config['site_start']));
          }
          ?>
          
            follow me on twitter: @dimmy01
            • 7455
            • 2,204 Posts
            you forgot this line in the top of your code:
            $wuid = ’-’.$userid;
              follow me on twitter: @dimmy01
              • 25551 ☆ A M B ☆
              • 1,231 Posts
              Yeah I did miss that out however, creating a new account with the new settings is not working with the redirect properly.

              Still being redirect is I’m signed in as the user who created the document... takes me straight to the home page.

              In the database it says createdby 0 and publishedby 0

              if($mode=="new"){   
              $wuid = '-'.$userid;
              	$table_name = $modx->getFullTableName( 'site_content' );
              	$fields = array(
                                      'type'	=>  'document',
              			'contentType'	=> 'text/html',
              			'content'	=> '<div class="contentcontainer">[!WebLoginPE?!]</div>
              <div class="contentcontainer" style="text-align:left; background-color:#444; padding:40px 0 40px 20%">       
              [!Ditto? &tpl=`clientTPL`  &summarize=`15` &total=`9` &sortBy=`createdon` &sortDir=`ASC` &descendentDepth=`3` !]
              </div>
              ',
              			'pagetitle'	=> 'Your Design Pages',
              			'longtitle'	=> 'Main Design Pages Area',
              			'published'	=> '1', //is the page published?
              			'parent'	=> '58', //what is the parent of this new page?
              			'isfolder'	=> '1', // lets make this a folder
              			'template'	=> '21', //type template id here
              			'cacheable'	=> '0',
              			'createdby'	=> $wuid, 
              			'createdon'	=> time(),
              			'editedon'	=> time(),
              			'publishedon'	=> time(),
              			'hidemenu'	=> '1',
              			'privateweb' => '1',
              			
              			);
              	
              	$modx->db->insert( $fields, $table_name); // put the fields in the db (id wil be created incremental.)
              
              //Create  placeholder and put the id in a session to use for mail or whatever.
              $_SESSION['eigenpaginaid'] =  $modx->db->getInsertId();
              $modx->setPlaceholder('eigenpaginaid', $modx->db->getInsertId());
              $parent= $modx->db->getInsertId();
              
              //start of page creation, copy this part and past below for as many docs you want (I know we could use a loop but than the logtitle and page title are all the same)
              $fields = array(
                                      'type'	=>  'document',
              			'contentType'	=> 'text/html',
              			'content'	=> '<div class="contentcontainer">[[Jot? &pagination=`10` &captcha=`1` &action=`form,comments` &subjectModerate=`0` &tplComments=`clienttickethistory`  &tplForm=`clientticket` ]]</div>',
              			'pagetitle'	=> 'Ticket System',
              			'longtitle'	=> 'Raise A Ticket',
              			'published'	=> '1', //is the page published?
              			'parent'	=> $parent, //here we go create a doc in the first doc
              			'isfolder'	=> '0',
              			'template'	=> '21', //type template id here
              			'cacheable'	=> '0',
              			'createdby'	=> $wuid,
              			'createdon'	=> time(),
              			'editedon'	=> time(),
              			'publishedon'	=> time(),
              			'hidemenu'	=> '1',
              			'privateweb' => '1',
              		
              			);
              	
              	$modx->db->insert( $fields, $table_name); // put the fields in the db (id wil be created incremental.)
              //end of page creation
              
              
                 return;
              }
                Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
                AugmentBLU - MODX Partner

                BLUcart - MODX Revolution E-Commerce & Shopping Cart
                • 25551 ☆ A M B ☆
                • 1,231 Posts
                Here’s a list of my setup that may help figure out why the redirect isn’t working as I hoped.

                Snippets and setup

                login - Using webloginPE as the signup snippet. I do have custom fields that’s why it’s in the snippet call.

                [!WebLoginPE? &type=`register` &userImage=`500000,250,250`  &registerTpl=`registerTPL` &regHomeId=`29` &groups=`Registered Member` &dateFormat=`%d-%m-%Y` &regSuccessPause=`2` &customFields=`address1,address2,address3`!]


                once client fills in register form the ClientPages plugin is called

                if($mode=="new"){   
                $wuid = '-'.$userid;
                	$table_name = $modx->getFullTableName( 'site_content' );
                	$fields = array(
                                        'type'	=>  'document',
                			'contentType'	=> 'text/html',
                			'content'	=> '<div class="contentcontainer">[!WebLoginPE?!]</div>
                <div class="contentcontainer" style="text-align:left; background-color:#444; padding:40px 0 40px 20%">       
                [!Ditto? &tpl=`clientTPL`  &summarize=`15` &total=`9` &sortBy=`createdon` &sortDir=`ASC` &descendentDepth=`3` !]
                </div>
                ',
                			'pagetitle'	=> 'Your Design Pages',
                			'longtitle'	=> 'Main Design Pages Area',
                			'published'	=> '1', //is the page published?
                			'parent'	=> '58', //what is the parent of this new page?
                			'isfolder'	=> '1', // lets make this a folder
                			'template'	=> '21', //type template id here
                			'cacheable'	=> '0',
                			'createdby'	=> $wuid, 
                			'createdon'	=> time(),
                			'editedon'	=> time(),
                			'publishedon'	=> time(),
                			'hidemenu'	=> '1',
                
                			
                			);
                	
                	$modx->db->insert( $fields, $table_name); // put the fields in the db (id wil be created incremental.)
                
                //Create  placeholder and put the id in a session to use for mail or whatever.
                $_SESSION['eigenpaginaid'] =  $modx->db->getInsertId();
                $modx->setPlaceholder('eigenpaginaid', $modx->db->getInsertId());
                $parent= $modx->db->getInsertId();
                
                //start of page creation, copy this part and past below for as many docs you want (I know we could use a loop but than the logtitle and page title are all the same)
                $fields = array(
                                        'type'	=>  'document',
                			'contentType'	=> 'text/html',
                			'content'	=> '<div class="contentcontainer">[[Jot? &pagination=`10` &captcha=`1` &action=`form,comments` &subjectModerate=`0` &tplComments=`clienttickethistory`  &tplForm=`clientticket` ]]</div>',
                			'pagetitle'	=> 'Ticket System',
                			'longtitle'	=> 'Raise A Ticket',
                			'published'	=> '1', //is the page published?
                			'parent'	=> $parent, //here we go create a doc in the first doc
                			'isfolder'	=> '0',
                			'template'	=> '21', //type template id here
                			'cacheable'	=> '0',
                			'createdby'	=> $wuid,
                			'createdon'	=> time(),
                			'editedon'	=> time(),
                			'publishedon'	=> time(),
                			'hidemenu'	=> '1',
                
                		
                			);
                	
                	$modx->db->insert( $fields, $table_name); // put the fields in the db (id wil be created incremental.)
                //end of page creation
                
                
                   return;
                }



                Pages created in MODX manager as it should. Database shows createdby as 0




                clientRedirect snippet

                <?php
                if($_SESSION["usertype"] == "manager") {$manager = "1";}
                $wuid  = "-".$modx->getLoginUserID();
                $owner =  $modx->documentObject['createdby'];
                if($wuid == $owner || $manager == "1"){
                return;
                }else{
                $modx->sendRedirect($modx->makeUrl($modx->config['site_start']));
                }
                ?>


                called using TV

                [*clientRedirect*]
                checkbox
                clientRedirect==[[clientRedirect]]


                On the page that was created I check the clientRedirect checkbox to activate the snippet.

                Admin can navigate but the creator is being redirected as is anyother person other than admin.

                Do you need anymore information? I could give you access to see if there’s something up?

                  Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
                  AugmentBLU - MODX Partner

                  BLUcart - MODX Revolution E-Commerce & Shopping Cart
                  • 7455
                  • 2,204 Posts
                  the only problem we need to solve is why the webuser id is not saved to the DB

                  maybe WebloginPE uses another variable for the new webuser id? I use this with the shipped snippet websignup and it works good.
                    follow me on twitter: @dimmy01
                    • 25551 ☆ A M B ☆
                    • 1,231 Posts
                    Oh no!

                    Do you think I’ll be able to get it sorted out?


                    database tables that i see webloginPE uses are


                    modx_web_users
                    id username password cachepwd

                    modx_web_groups
                    id webgroup webuser

                    modx_web_user_attributes
                    id internalKey fullname role email
                    phone mobilephone blocked blockeduntil
                    blockedafter logincount lastlogin thislogin
                    failedlogincount sessionid dob gender
                    country state zip fax photo
                      Ross Sivills - MD AugmentBLU Edinburgh, Scotland UK
                      AugmentBLU - MODX Partner

                      BLUcart - MODX Revolution E-Commerce & Shopping Cart
                      • 7455
                      • 2,204 Posts
                      ok webloginPE uses another techniek

                      instead of the userid it uses an array $user[’id’] (I think that this is the right one)

                      try changing $wuid = ’-’.$userid; to $wuid = ’-’.$user[’id’]; see if that works
                        follow me on twitter: @dimmy01