discuss.answer
I think this version of CheckProfile will do it.
<?php
function generateOutput($old, $new, &$msg) {
foreach($old as $key => $oldValue) {
if (is_array($oldValue)) {
$msg .= generateOutput($oldValue, $new[$key], $msg);
} else {
$newValue = empty($new[$key])? '(empty)' : $new[$key];
$oldValue = empty($oldValue)? '(empty)' : $oldValue;
if ($newValue != $oldValue) {
$msg .= "\n" . $key . ' changed from ' . $oldValue . ' to ' . $newValue;
}
}
}
}
$oldProfile = isset($_SESSION['user_profile'])? $_SESSION['user_profile'] : 'No Profile';
$newProfile = $modx->user->getOne('Profile')->toArray();
$msg = '';
generateOutput($oldProfile, $newProfile, $msg);
/* foreach($oldProfile as $key => $oldValue) {
$msg .= generateOutput(
$newValue = empty($newProfile[$key])? '(empty)' : $newProfile[$key];
$oldValue = empty($oldValue)? '(empty)' : $oldValue;
if ($newValue != $oldValue) {
$msg .= "\n" . $key . ' changed from ' . $oldValue . ' to ' . $newValue;
}
}
*/
/* Email $msg here after debugging */
/* When through debugging, comment out
these three lines */
$chunk = $modx->getObject('modChunk', array('name' => 'Debug'));
$chunk->setContent($msg);
$chunk->save();
return true;
Bob - you are the man! Works a treat - thank you soooooo much for helping here and working so hard with me to get it working - what an asset to the MODX solution you are! True legend. Thank you.
Thanks for the kind words -- sorry it took so long to get it right. Did I mention that Bob's Guides accepts donations?
http://bobsguides.com/support-this-site.html
About the $msg variable, can't you just do this?
mail($to, $subject, $msg, $headers);
You shouldn't need the debug chunk at all.
Thank you!