Just managed to figure it out
For anyone want to change a page based on the webusers pre selected selction you can do this:
Requirements
1) You must already be storing the users template selection in a database for myself i stored this template name in a custom table called modx_web_user_details and the field was called template_name
2) For my site it looks up the logged in webuser and pulls the ID to get the query.
TemplateSwitch Plugin
$id = $modx->documentIdentifier;
$tv = $modx->getTemplateVarOutput(array("TemplateSwitch"), $id);
$templateswitch = $tv["TemplateSwitch"];
if ($templateswitch == "yes") {
$usernameid = $modx->getLoginUserID();
$table = $modx->getFullTableName("web_user_details");
$result = $modx->db->select("template_name",$table,"webuser = ’" .$usernameid ."’");
if($modx->db->getRecordCount($result) == 1) {
$row = $modx->db->getRow($result);
$template_name = $row[’template_name’];
}
if ($template_name != "") {
$table = $modx->getFullTableName("site_templates");
$result = $modx->db->select("id, content",$table,"templatename = ’" .$template_name ."’");
if($modx->db->getRecordCount($result) == 1) {
$row = $modx->db->getRow($result);
$modx->documentObject[’template’]=$row[’id’];
$modx->documentContent = $row[’content’];
} else {
$this->messageQuit("Error retrieving template.");
}
}
}
Create a TV called "TemplateSwitcher"
Input Type: Radio Options
Input Option Values: yes||no
Default Value: no
Assign this to your websites main template
Now for any pages which you want to apply the template switcher to simply set the radio option on that page to Yes.