I need to automatically generate the SiteTree (Page) node (after the user registration) but the following code add an empty node in the Menu (Site) Tree and cause an error while deleting in the CMS editor.
<code>
class SubjectPage extends Page { ... }
class RegistrationFormPage_Controller extends Page_Controller {
...
function SignUpAction($data, $form) {
...
$subject2 = DataObject::get_by_id("SubjectPage", 19);
$subject = $subject2->duplicate(true);
$subject->setParent(13);
$subject->Title = $data['Nick'];
$subject->setMenuTitle($data['Nick']);
$subject->write();
...
}
}
</code>
What's wrong?