<?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']));
}
Also to expand the idea slightly, using the plugin you gave me, how could i generate a parent document and say 3 child documents in one go? I have the plugin working to create a parent doc so how could I generate 2 or 3 documents in one go?
<?php //only for the nice colors (so do not copy this line!!! plugins do not use this tag!!!)
if($mode=="new"){
$wuid = '-'.$userid;
$table_name = $modx->getFullTableName( 'site_content' );
$fields = array(
'type' => 'document',
'contentType' => 'texthtml',
'pagetitle' => 'pagetitle',
'longtitle' => 'my longtitle goes here',
'published' => '1', //is the page published?
'parent' => '60', //what is the parent of this new page?
'isfolder' => '1', // lets make this a folder
'template' => '1', //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' => 'texthtml',
'pagetitle' => 'pagetitle',
'longtitle' => 'my longtitle goes here',
'published' => '1', //is the page published?
'parent' => $parent, //here we go create a doc in the first doc
'isfolder' => '0',
'template' => '1', //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;
}
Also, the id of the current page is the default if you don’t specify a startID or parents parameter.