<![CDATA[ Login Register Pre/Post Hook wont work... - My Forums]]> https://forums.modx.com/thread/?thread=100829 <![CDATA[Login Register Pre/Post Hook wont work...]]> https://forums.modx.com/thread/100829/login-register-pre-post-hook-wont-work?page=2#dis-post-544602
// get values from qualification, project and account forms

$qualificiation_areyou = $hook->getValue('qualificiation_areyou');
$qualificiation_emailaddress = $hook->getValue('qualificiation_emailaddress');


// set TVs to values as per form data

$projectFolderID = 19;
$doc = $modx->getObject('modDocument',$projectFolderID);

$doc->setTVValue(32, $qualificiation_areyou);
$doc->setTVValue(33, $qualificiation_emailaddress);


return true;


So, I am getting the form field values of fields "qualificiation_areyou" and "qualificiation_emailaddress" in the snippet, then defining the modx resource I want to set the TVs on - e.g. id=19, then setting the TVs (e.g. 32 and 33) to the values of the form fields "qualificiation_areyou" and "qualificiation_emailaddress" respectively...

Why is this not working??]]>
dubbs Aug 31, 2016, 08:46 AM https://forums.modx.com/thread/100829/login-register-pre-post-hook-wont-work?page=2#dis-post-544602
<![CDATA[Re: Login Register Pre/Post Hook wont work...]]> https://forums.modx.com/thread/100829/login-register-pre-post-hook-wont-work?page=2#dis-post-544633 ]]> BobRay Aug 31, 2016, 04:49 PM https://forums.modx.com/thread/100829/login-register-pre-post-hook-wont-work?page=2#dis-post-544633 <![CDATA[Re: Login Register Pre/Post Hook wont work...]]> https://forums.modx.com/thread/100829/login-register-pre-post-hook-wont-work?page=2#dis-post-544632

Cheers. dubbs.]]>
dubbs Aug 31, 2016, 04:21 PM https://forums.modx.com/thread/100829/login-register-pre-post-hook-wont-work?page=2#dis-post-544632
<![CDATA[Re: Login Register Pre/Post Hook wont work...]]> https://forums.modx.com/thread/100829/login-register-pre-post-hook-wont-work?page=2#dis-post-544631 Quote from: BobRay at Aug 31, 2016, 04:13 PM
That's not a new line. Just pointing out that the 'ID' in your $projectFolder variable in one place doesn't match the 'Id' in another.

Change them all to 'ID' and you should be in business.


Ahh I see... wink Will give it a go...]]>
dubbs Aug 31, 2016, 04:17 PM https://forums.modx.com/thread/100829/login-register-pre-post-hook-wont-work?page=2#dis-post-544631
<![CDATA[Re: Login Register Pre/Post Hook wont work...]]> https://forums.modx.com/thread/100829/login-register-pre-post-hook-wont-work?page=2#dis-post-544630
Change them all to 'ID' and you should be in business.

]]>
BobRay Aug 31, 2016, 04:13 PM https://forums.modx.com/thread/100829/login-register-pre-post-hook-wont-work?page=2#dis-post-544630
<![CDATA[Re: Login Register Pre/Post Hook wont work...]]> https://forums.modx.com/thread/100829/login-register-pre-post-hook-wont-work?page=2#dis-post-544628 Quote from: BobRay at Aug 31, 2016, 03:14 PM
I do. $projectFolderId !== $projectFolderID. wink My mistake.

Thanks Bob - where do I drop this line in?]]>
dubbs Aug 31, 2016, 03:17 PM https://forums.modx.com/thread/100829/login-register-pre-post-hook-wont-work?page=2#dis-post-544628
<![CDATA[Re: Login Register Pre/Post Hook wont work...]]> https://forums.modx.com/thread/100829/login-register-pre-post-hook-wont-work?page=2#dis-post-544626 My mistake.]]> BobRay Aug 31, 2016, 03:14 PM https://forums.modx.com/thread/100829/login-register-pre-post-hook-wont-work?page=2#dis-post-544626 <![CDATA[Re: Login Register Pre/Post Hook wont work...]]> https://forums.modx.com/thread/100829/login-register-pre-post-hook-wont-work?page=2#dis-post-544623
Good news is that now does not make the submission fall over...

Bad news is that it still does not set the value of the TV in resource 19.... have no idea why!]]>
dubbs Aug 31, 2016, 03:06 PM https://forums.modx.com/thread/100829/login-register-pre-post-hook-wont-work?page=2#dis-post-544623
<![CDATA[Re: Login Register Pre/Post Hook wont work...]]> https://forums.modx.com/thread/100829/login-register-pre-post-hook-wont-work#dis-post-544621
$qualificiation_areyou = $hook->getValue('qualificiation_areyou');
$qualificiation_emailaddress = $hook->getValue('qualificiation_emailaddress');
  
  
// set TVs to values as per form data
$projectFolderID = 19;
$tvr = $modx->getObject('modTemplateVarResource', (array('contentid' => $projectFolderID, 'tmplvarid' => 32)));

if ($tvr) {
    $tvr->set('value', $qualificiation_areyou);

} else {
    $tvr = $modx->newObject('modTemplateVarResource');
    $tvr->set('contentid', $projectFolderId);
    $tvr->set('tmplvarid', 32);
    $tvr->set('value', $qualificiation_areyou);
}
    $tvr->save();


 
$tvr = $modx->getObject('modTemplateVarResource', (array('contentid' => $projectFolderID, 'tmplvarid' => 33)));

if ($tvr) {
    $tvr->set('value', $qualificiation_emailaddress);
} else {
    $tvr = $modx->newObject('modTemplateVarResource');
    $tvr->set('contentid', $projectFolderID);
    $tvr->set('tmplvarid', 33);
    $tvr->set('value', $qualificiation_emailaddress);
}
$tvr->save();
 
return true;


I hope this is right. I'm on vacation in Paris and using a laptop with a very small screen, so it's hard to see typos.
]]>
BobRay Aug 31, 2016, 02:57 PM https://forums.modx.com/thread/100829/login-register-pre-post-hook-wont-work#dis-post-544621
<![CDATA[Re: Login Register Pre/Post Hook wont work...]]> https://forums.modx.com/thread/100829/login-register-pre-post-hook-wont-work#dis-post-544620 dubbs Aug 31, 2016, 02:47 PM https://forums.modx.com/thread/100829/login-register-pre-post-hook-wont-work#dis-post-544620