Ok the auto generation plugin is as follows now.
if($mode=="new"){
$wuid = '-'.$user['internalKey'];
$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;
}
system event is set to OnWebSaveUser
Redirect snippet is as follows
<?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']));
}
?>
The same thing is happening... when accessing without being signed in, it’s redirecting as it should. Signin with the username that just created the pages, it’s being redirected to the home page. Admin can access the pages.